2 new revisions:
Revision: 831f6d83b907
Branch: default
Author: Pekka Klärck
Date: Wed Jun 4 12:43:35 2014 UTC
Log: listeners: refactored reading attributes sent to listeners
http://code.google.com/p/robotframework/source/detail?r=831f6d83b907
Revision: 9915137f57b4
Branch: default
Author: Pekka Klärck
Date: Wed Jun 4 13:08:57 2014 UTC
Log: Add 'id' to attributes passed to listeners....
http://code.google.com/p/robotframework/source/detail?r=9915137f57b4
==============================================================================
Revision: 831f6d83b907
Branch: default
Author: Pekka Klärck
Date: Wed Jun 4 12:43:35 2014 UTC
Log: listeners: refactored reading attributes sent to listeners
http://code.google.com/p/robotframework/source/detail?r=831f6d83b907
Modified:
/src/robot/output/listeners.py
=======================================
--- /src/robot/output/listeners.py Tue May 27 14:43:45 2014 UTC
+++ /src/robot/output/listeners.py Wed Jun 4 12:43:35 2014 UTC
@@ -53,8 +53,9 @@
class Listeners(object):
__metaclass__ = _RecursionAvoidingMetaclass
- _start_attrs = ['doc', 'starttime', 'longname']
- _end_attrs = _start_attrs +
['endtime', 'elapsedtime', 'status', 'message']
+ _start_attrs = ('doc', 'starttime', 'longname')
+ _end_attrs = _start_attrs +
('endtime', 'elapsedtime', 'status', 'message')
+ _kw_extra_attrs = ('args', '-longname', '-message')
def __init__(self, listeners):
self._listeners = self._import_listeners(listeners)
@@ -132,7 +133,7 @@
if li.version == 1:
li.call_method(li.start_keyword, kw.name, kw.args)
else:
- attrs = self._get_start_attrs(kw, 'args', '-longname')
+ attrs = self._get_start_attrs(kw, *self._kw_extra_attrs)
attrs['type'] = self._get_keyword_type(kw, start=True)
li.call_method(li.start_keyword, kw.name, attrs)
@@ -141,7 +142,7 @@
if li.version == 1:
li.call_method(li.end_keyword, kw.status)
else:
- attrs =
self._get_end_attrs(kw, 'args', '-longname', '-message')
+ attrs = self._get_end_attrs(kw, *self._kw_extra_attrs)
attrs['type'] = self._get_keyword_type(kw, start=False)
li.call_method(li.end_keyword, kw.name, attrs)
@@ -181,23 +182,23 @@
for li in self._listeners:
li.call_method(li.close)
- def _get_start_attrs(self, item, *names):
- return self._get_attrs(item, self._start_attrs, names)
+ def _get_start_attrs(self, item, *extra):
+ return self._get_attrs(item, self._start_attrs, extra)
- def _get_end_attrs(self, item, *names):
- return self._get_attrs(item, self._end_attrs, names)
+ def _get_end_attrs(self, item, *extra):
+ return self._get_attrs(item, self._end_attrs, extra)
- def _get_attrs(self, item, defaults, extras):
- names = self._get_attr_names(defaults, extras)
+ def _get_attrs(self, item, default, extra):
+ names = self._get_attr_names(default, extra)
return dict((n, self._get_attr_value(item, n)) for n in names)
- def _get_attr_names(self, defaults, extras):
- names = list(defaults)
- for name in extras:
- if name.startswith('-'):
+ def _get_attr_names(self, default, extra):
+ names = list(default)
+ for name in extra:
+ if not name.startswith('-'):
+ names.append(name)
+ elif name[1:] in names:
names.remove(name[1:])
- else:
- names.append(name)
return names
def _get_attr_value(self, item, name):
==============================================================================
Revision: 9915137f57b4
Branch: default
Author: Pekka Klärck
Date: Wed Jun 4 13:08:57 2014 UTC
Log: Add 'id' to attributes passed to listeners.
Update issue 1725
Status: Done
Owner: pekka.klarck
Implemented, tested, and documented.
http://code.google.com/p/robotframework/source/detail?r=9915137f57b4
Modified:
/atest/robot/output/listener_interface/listener_methods.txt
/atest/testresources/listeners/JavaAttributeVerifyingListener.class
/atest/testresources/listeners/JavaAttributeVerifyingListener.java
/atest/testresources/listeners/ListenAll.py
/atest/testresources/listeners/attributeverifyinglistener.py
/atest/testresources/listeners/module_listener.py
/doc/userguide/src/ExtendingRobotFramework/ListenerInterface.rst
/src/robot/output/listeners.py
=======================================
--- /atest/robot/output/listener_interface/listener_methods.txt Tue May 28
08:19:31 2013 UTC
+++ /atest/robot/output/listener_interface/listener_methods.txt Wed Jun 4
13:08:57 2014 UTC
@@ -56,14 +56,14 @@
${status} = Log File %{TEMPDIR}/${ATTR_TYPE_FILE}
Check Stderr Does Not Contain attributeverifyinglistener
Should Not Contain ${status} FAILED
- Should Contain X Times ${status} PASSED 163
+ Should Contain X Times ${status} PASSED 169
Correct Attributes To Java Listener Methods
[Tags] jybot
${status} = Log File %{TEMPDIR}/${JAVA_ATTR_TYPE_FILE}
Check Stderr Does Not Contain JavaAttributeVerifyingListener
Should Not Contain ${status} FAILED
- Should Contain X Times ${status} PASSED 163
+ Should Contain X Times ${status} PASSED 169
Suite And Test Counts
Run Tests --listener listeners.SuiteAndTestCounts misc/suites/sub*
@@ -107,7 +107,7 @@
Check Listen All File
[Arguments] ${filename}
@{expected}= Create List Got settings on level: INFO
- ... SUITE START: Pass And Fail 'Some tests here' [ListenerMeta: Hello]
+ ... SUITE START: Pass And Fail (s1) 'Some tests here' [ListenerMeta:
Hello]
... KW START: My Keyword ['Suite Setup']
... KW START: BuiltIn.Log ['Hello says "\${who}"!', '\${LEVEL1}']
... LOG MESSAGE: [INFO] Hello says "Suite Setup"!
@@ -116,7 +116,7 @@
... LOG MESSAGE: [DEBUG] Debug message
... KW END: PASS
... KW END: PASS
- ... TEST START: Pass '' ['force', 'pass'] crit: yes
+ ... TEST START: Pass (s1-t1) '' ['force', 'pass'] crit: yes
... KW START: My Keyword ['Pass']
... KW START: BuiltIn.Log ['Hello says "\${who}"!', '\${LEVEL1}']
... LOG MESSAGE: [INFO] Hello says "Pass"!
@@ -126,7 +126,7 @@
... KW END: PASS
... KW END: PASS
... TEST END: PASS crit: yes
- ... TEST START: Fail 'FAIL Expected failure' ['fail', 'force'] crit:
no
+ ... TEST START: Fail (s1-t2) 'FAIL Expected failure'
['fail', 'force'] crit: no
... KW START: My Keyword ['Fail']
... KW START: BuiltIn.Log ['Hello says "\${who}"!', '\${LEVEL1}']
... LOG MESSAGE: [INFO] Hello says "Fail"!
=======================================
--- /atest/testresources/listeners/JavaAttributeVerifyingListener.class Tue
May 28 08:19:31 2013 UTC
+++ /atest/testresources/listeners/JavaAttributeVerifyingListener.class Wed
Jun 4 13:08:57 2014 UTC
@@ -90,25 +90,22 @@
! Y Z S S 7* , ½ Y SY SY SY SY SY SY
SY
+SY
S·
-± T
$ 6 & [ Z S q U* ,
-½ Y SY SY SY SY SY SY
SY
-SY SY !SY
+SY
+SY !SY
"SY
#SY
- $S·
-± T
+ $SY
+ %S· ± U
) T + \ Z S G +* %, ½ Y SY SY SY &SY 'SY (S·
-± T
. * 0 ] Z S _ C* ),
½ Y SY SY SY &SY 'SY (SY SY !SY "SY #S·
-± T
+ $S· ± U
3 B 5 ^ Z S < * *, ½ Y SY SY +SY ,S·
-± T
8 : _ Z S M 1* -, ½ Y SY SY +SY ,SY
SY !SY "S·
-± T
= 0 ? ` R S $ *´ ¶ .± T
B C U V a b S l
*´ » Y· +¶ /¶ ¶
=======================================
--- /atest/testresources/listeners/JavaAttributeVerifyingListener.java Tue
May 28 08:19:31 2013 UTC
+++ /atest/testresources/listeners/JavaAttributeVerifyingListener.java Wed
Jun 4 13:08:57 2014 UTC
@@ -34,22 +34,22 @@
public void startSuite(String name, Map attrs) {
verifyAttributes("START SUITE", attrs,
- new String[]
{"doc", "starttime", "longname", "source", "metadata", "tests", "suites", "totaltests"});
+ new String[]
{"id", "doc", "starttime", "longname", "source", "metadata", "tests", "suites", "totaltests"});
}
public void endSuite(String name, Map attrs) {
verifyAttributes("END SUITE", attrs,
- new String[]
{"doc", "starttime", "longname", "source", "metadata", "tests", "suites", "totaltests", "endtime", "elapsedtime", "status", "message", "statistics"});
+ new String[]
{"id", "doc", "starttime", "longname", "source", "metadata", "tests", "suites", "totaltests", "endtime", "elapsedtime", "status", "message", "statistics"});
}
public void startTest(String name, Map attrs) {
verifyAttributes("START TEST", attrs,
- new String[]
{"doc", "starttime", "longname", "tags", "critical", "template"});
+ new String[]
{"id", "doc", "starttime", "longname", "tags", "critical", "template"});
}
public void endTest(String name, Map attrs) {
verifyAttributes("END TEST", attrs,
- new String[]
{"doc", "starttime", "longname", "tags", "critical", "template", "endtime", "elapsedtime", "status", "message"});
+ new String[]
{"id", "doc", "starttime", "longname", "tags", "critical", "template", "endtime", "elapsedtime", "status", "message"});
}
public void startKeyword(String name, Map attrs) {
=======================================
--- /atest/testresources/listeners/ListenAll.py Wed Sep 12 22:17:39 2012 UTC
+++ /atest/testresources/listeners/ListenAll.py Wed Jun 4 13:08:57 2014 UTC
@@ -14,13 +14,13 @@
def start_suite(self, name, attrs):
metastr = ' '.join('%s: %s' % (k, v) for k, v in
attrs['metadata'].items())
- self.outfile.write("SUITE START: %s '%s' [%s]\n"
- % (name, attrs['doc'], metastr))
+ self.outfile.write("SUITE START: %s (%s) '%s' [%s]\n"
+ % (name, attrs['id'], attrs['doc'], metastr))
def start_test(self, name, attrs):
tags = [str(tag) for tag in attrs['tags']]
- self.outfile.write("TEST START: %s '%s' %s crit: %s\n"
- % (name, attrs['doc'], tags,
attrs['critical']))
+ self.outfile.write("TEST START: %s (%s) '%s' %s crit: %s\n"
+ % (name, attrs['id'], attrs['doc'], tags,
attrs['critical']))
def start_keyword(self, name, attrs):
args = [str(arg) for arg in attrs['args']]
=======================================
--- /atest/testresources/listeners/attributeverifyinglistener.py Tue May 28
08:19:31 2013 UTC
+++ /atest/testresources/listeners/attributeverifyinglistener.py Wed Jun 4
13:08:57 2014 UTC
@@ -12,19 +12,19 @@
def start_suite(name, attrs):
_verify_attrs('START SUITE', attrs,
- START_ATTRS + 'longname metadata source tests suites
totaltests')
+ START_ATTRS + 'id longname metadata source tests suites
totaltests')
def end_suite(name, attrs):
_verify_attrs('END SUITE', attrs,
- END_ATTRS + 'longname metadata source tests suites
totaltests statistics message')
+ END_ATTRS + 'id longname metadata source tests suites
totaltests statistics message')
def start_test(name, attrs):
_verify_attrs('START TEST', attrs,
- START_ATTRS + 'longname tags critical template')
+ START_ATTRS + 'id longname tags critical template')
def end_test(name, attrs):
_verify_attrs('END TEST', attrs,
- END_ATTRS + 'longname tags critical message template')
+ END_ATTRS + 'id longname tags critical message template')
def start_keyword(name, attrs):
_verify_attrs('START KEYWORD', attrs, START_ATTRS + 'args type')
=======================================
--- /atest/testresources/listeners/module_listener.py Wed Sep 12 22:17:39
2012 UTC
+++ /atest/testresources/listeners/module_listener.py Wed Jun 4 13:08:57
2014 UTC
@@ -7,13 +7,13 @@
def start_suite(name, attrs):
metastr = ' '.join('%s: %s' % (k, v) for k, v in
attrs['metadata'].items())
- OUTFILE.write("SUITE START: %s '%s' [%s]\n"
- % (name, attrs['doc'], metastr))
+ OUTFILE.write("SUITE START: %s (%s) '%s' [%s]\n"
+ % (name, attrs['id'], attrs['doc'], metastr))
def start_test(name, attrs):
tags = [str(tag) for tag in attrs['tags']]
- OUTFILE.write("TEST START: %s '%s' %s crit: %s\n"
- % (name, attrs['doc'], tags, attrs['critical']))
+ OUTFILE.write("TEST START: %s (%s) '%s' %s crit: %s\n"
+ % (name, attrs['id'], attrs['doc'], tags,
attrs['critical']))
def start_keyword(name, attrs):
args = [str(arg) for arg in attrs['args']]
=======================================
--- /doc/userguide/src/ExtendingRobotFramework/ListenerInterface.rst Mon
Oct 15 10:52:11 2012 UTC
+++ /doc/userguide/src/ExtendingRobotFramework/ListenerInterface.rst Wed
Jun 4 13:08:57 2014 UTC
@@ -89,6 +89,9 @@
+===============+==================+==================================================+
| start_suite | name, attributes | Keys in the attribute
dictionary: |
| |
| |
+ | | | * id: suite id. 's1' for top level
suite, 's1-s1'|
+ | | | for its first child
suite, 's1-s2' for second |
+ | | | child, and so on. (new in 2.8.5)
| | | * longname: suite name including
parent suites |
| | | * doc: test suite
documentation |
| | | * metadata: dictionary/map
containing `free test |
@@ -106,6 +109,9 @@
+---------------+------------------+--------------------------------------------------+
| end_suite | name, attributes | Keys in the attribute
dictionary: |
| |
| |
+ | | | * id: suite id. 's1' for top level
suite, 's1-s1'|
+ | | | for its first child
suite, 's1-s2' for second |
+ | | | child, and so on. (new in 2.8.5)
| | | * longname: test suite name
including parents |
| | | * doc: test suite
documentation |
| | | * metadata: dictionary/map
containing `free test |
@@ -124,6 +130,9 @@
+---------------+------------------+--------------------------------------------------+
| start_test | name, attributes | Keys in the attribute
dictionary: |
| |
| |
+ | | | * id: test id in format
like 's1-s2-t2', where |
+ | | | beginning is parent suite id and
last part |
+ | | | shows test index in that suite
(new in 2.8.5) |
| | | * longname: test name including
parent suites |
| | | * doc: test case
documentation |
| | | * tags: test case tags as a list
of strings |
@@ -136,6 +145,9 @@
+---------------+------------------+--------------------------------------------------+
| end_test | name, attributes | Keys in the attribute
dictionary: |
| |
| |
+ | | | * id: test id in format
like 's1-s2-t2', where |
+ | | | beginning is parent suite id and
last part |
+ | | | shows test index in that suite
(new in 2.8.5) |
| | | * longname: test name including
parent suites |
| | | * doc: test case
documentation |
| | | * tags: test case tags as a list
of strings |
=======================================
--- /src/robot/output/listeners.py Wed Jun 4 12:43:35 2014 UTC
+++ /src/robot/output/listeners.py Wed Jun 4 13:08:57 2014 UTC
@@ -53,9 +53,9 @@
class Listeners(object):
__metaclass__ = _RecursionAvoidingMetaclass
- _start_attrs = ('doc', 'starttime', 'longname')
+ _start_attrs = ('id', 'doc', 'starttime', 'longname')
_end_attrs = _start_attrs +
('endtime', 'elapsedtime', 'status', 'message')
- _kw_extra_attrs = ('args', '-longname', '-message')
+ _kw_extra_attrs = ('args', '-id', '-longname', '-message')
def __init__(self, listeners):
self._listeners = self._import_listeners(listeners)
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.