3 new revisions:
Revision: 6b96cb5f6359
Author: Pekka Klärck
Date: Thu Feb 23 04:06:38 2012
Log: non-mutable default
http://code.google.com/p/robotframework/source/detail?r=6b96cb5f6359
Revision: bd7abbc4c928
Author: Pekka Klärck
Date: Thu Feb 23 04:07:13 2012
Log: testdoc: 1) print outfile to console, 2) factory for unit testing
purp...
http://code.google.com/p/robotframework/source/detail?r=bd7abbc4c928
Revision: 663c61d20364
Author: Pekka Klärck
Date: Thu Feb 23 05:40:26 2012
Log: testdoc: Fixed ids and test setup/keyword, some cleanup. This now
has ...
http://code.google.com/p/robotframework/source/detail?r=663c61d20364
==============================================================================
Revision: 6b96cb5f6359
Author: Pekka Klärck
Date: Thu Feb 23 04:06:38 2012
Log: non-mutable default
http://code.google.com/p/robotframework/source/detail?r=6b96cb5f6359
Modified:
/src/robot/conf/settings.py
=======================================
--- /src/robot/conf/settings.py Mon Feb 6 05:44:36 2012
+++ /src/robot/conf/settings.py Thu Feb 23 04:06:38 2012
@@ -55,11 +55,11 @@
'StdErr' : ('stderr', None)}
_output_opts = ['Output', 'Log', 'Report', 'DebugFile', 'XUnitFile']
- def __init__(self, options={}, log=True):
+ def __init__(self, options=None, log=True):
self._opts = {}
self._cli_opts = self._cli_opts.copy()
self._cli_opts.update(self._extra_cli_opts)
- self._process_cli_opts(options, log)
+ self._process_cli_opts(options or {}, log)
if log: LOGGER.info('Settings:\n%s' % unicode(self))
def _process_cli_opts(self, opts, log):
==============================================================================
Revision: bd7abbc4c928
Author: Pekka Klärck
Date: Thu Feb 23 04:07:13 2012
Log: testdoc: 1) print outfile to console, 2) factory for unit testing
purposes
http://code.google.com/p/robotframework/source/detail?r=bd7abbc4c928
Modified:
/src/robot/testdoc.py
=======================================
--- /src/robot/testdoc.py Wed Feb 22 23:36:43 2012
+++ /src/robot/testdoc.py Thu Feb 23 04:07:13 2012
@@ -41,6 +41,7 @@
$ testdoc.py mytestcases.html testdoc.html
$ testdoc.py --name smoke_test_plan --include smoke path/to/my_tests/
doc.html
"""
+
import sys
import os
import codecs
@@ -57,16 +58,18 @@
populators.PROCESS_CURDIR = False
+
class TestDoc(utils.Application):
def __init__(self):
utils.Application.__init__(self, USAGE, arg_limits=(2,),
auto_version=False)
- def main(self, args, title=None, **opts):
+ def main(self, args, title=None, **options):
datasources = args[0:-1]
- outfile = args[-1]
- suite = TestSuite(datasources, RobotSettings(opts))
+ outfile = os.path.abspath(args[-1])
+ suite = TestSuiteFactory(datasources, options)
self._write_test_doc(suite, outfile, title)
+ self.console(outfile)
def _write_test_doc(self, suite, outfile, title):
output = codecs.open(outfile, 'w', 'UTF-8')
@@ -75,6 +78,12 @@
output.close()
+def TestSuiteFactory(datasources, options=None):
+ if isinstance(datasources, basestring):
+ datasources = [datasources]
+ return TestSuite(datasources, RobotSettings(options))
+
+
class TestdocModelWriter(ModelWriter):
def __init__(self, output, suite, title):
==============================================================================
Revision: 663c61d20364
Author: Pekka Klärck
Date: Thu Feb 23 05:40:26 2012
Log: testdoc: Fixed ids and test setup/keyword, some cleanup. This now
has unit tests but they are still work-in-progress. Committing sources
separately now because Mikko needs them.
http://code.google.com/p/robotframework/source/detail?r=663c61d20364
Modified:
/src/robot/testdoc.py
=======================================
--- /src/robot/testdoc.py Thu Feb 23 04:07:13 2012
+++ /src/robot/testdoc.py Thu Feb 23 05:40:26 2012
@@ -67,7 +67,7 @@
def main(self, args, title=None, **options):
datasources = args[0:-1]
outfile = os.path.abspath(args[-1])
- suite = TestSuiteFactory(datasources, options)
+ suite = TestSuiteFactory(datasources, **options)
self._write_test_doc(suite, outfile, title)
self.console(outfile)
@@ -78,7 +78,7 @@
output.close()
-def TestSuiteFactory(datasources, options=None):
+def TestSuiteFactory(datasources, **options):
if isinstance(datasources, basestring):
datasources = [datasources]
return TestSuite(datasources, RobotSettings(options))
@@ -105,62 +105,52 @@
class JsonConverter(object):
def convert(self, suite):
- return self._convert_suite(suite, 's-0')
-
- def _convert_suite(self, suite, suite_id, index=None):
- suite_id = self._get_id(suite_id, 's', index) if index is not None
else suite_id
+ return self._convert_suite(suite)
+
+ def _convert_suite(self, suite):
return {
+ 'source': suite.source,
+ 'id': suite.id,
'name': suite.name,
'fullName': suite.longname,
- 'source': suite.source,
'doc': suite.doc,
- 'id': suite_id,
'metadata': dict(suite.metadata),
'numberOfTests': suite.get_test_count(),
- 'suites': self._convert_suites(suite, suite_id),
- 'tests': self._convert_tests(suite, suite_id),
- 'keywords': self._get_suite_keywords(suite, suite_id)
+ 'suites': self._convert_suites(suite),
+ 'tests': self._convert_tests(suite),
+ 'keywords': list(self._convert_keywords(suite))
}
- def _get_suite_keywords(self, suite, suite_id):
- kws = []
- if suite.setup.name:
- kws.append(self._convert_keyword(suite.setup, suite_id,
0, 'SETUP'))
- if suite.teardown.name:
- kws.append(self._convert_keyword(suite.teardown, suite_id,
1, 'TEARDOWN'))
- return kws
-
- def _convert_suites(self, suite, suite_id):
- return [self._convert_suite(suite, suite_id, index)
- for index, suite in enumerate(suite.suites)]
-
- def _convert_tests(self, suite, suite_id):
- return [self._convert_test(test, suite_id, index)
- for index, test in enumerate(suite.tests)]
-
- def _convert_test(self, test, suite_id, index):
- test_id = self._get_id(suite_id, 't', index)
+ def _convert_suites(self, suite):
+ return [self._convert_suite(s) for s in suite.suites]
+
+ def _convert_tests(self, suite):
+ return [self._convert_test(t) for t in suite.tests]
+
+ def _convert_test(self, test):
return {
'name': test.name,
'fullName': test.longname,
- 'id': test_id,
+ 'id': test.id,
'doc': test.doc,
'tags': utils.normalize_tags(test.tags),
'timeout': self._get_timeout(test.timeout),
- 'keywords': self._convert_keywords(test, test_id)
+ 'keywords': list(self._convert_keywords(test))
}
- def _convert_keywords(self, test, test_id):
- types = {'kw': 'KEYWORD', 'for': 'FOR'}
- return [self._convert_keyword(k, test_id, index, types[k.type])
- for index, k in enumerate(test.keywords)]
-
- def _convert_keyword(self, kw, test_id, index, type):
+ def _convert_keywords(self, item):
+ if item.setup.name:
+ yield self._convert_keyword(item.setup, type='SETUP')
+ for kw in getattr(item, 'keywords', []):
+ yield self._convert_keyword(kw)
+ if item.teardown.name:
+ yield self._convert_keyword(item.teardown, type='TEARDOWN')
+
+ def _convert_keyword(self, kw, type=None):
return {
'name': kw._get_name(kw.name) if isinstance(kw, Keyword) else
kw.name,
- 'id': test_id + '-k-%d' % index,
'arguments': ', '.join(kw.args),
- 'type': type
+ 'type': type or {'kw': 'KEYWORD', 'for': 'FOR'}[kw.type]
}
def _get_timeout(self, timeout):
@@ -169,15 +159,13 @@
except ValueError:
tout = timeout.string
if timeout.message:
- tout += ' | ' + timeout.message
+ tout += ' :: ' + timeout.message
return tout
- def _get_id(self, parent_id, type, index):
- return parent_id + '-%s-%d' % (type, index)
-
def testdoc_cli(args):
TestDoc().execute_cli(args)
+
if __name__ == '__main__':
testdoc_cli(sys.argv[1:])