0
的Jython V2.5 RobotFramework v2.7.5 的Log4j v1.2.16如何漂亮打印字典由robot.libraries.BuiltIn.BuiltIn.get_variables
我有一个Jython脚本作为listener用来记录variables
字典返回但pprint模块不像attributes
字典那么漂亮。
我使用BuiltIn().get_variables()函数来获取变量词典:
def start_suite(self, name, attributes):
self.LOGGER.info('<<<start_suite>>>')
self.LOGGER.debug('variables @ start suite: %s' % pprint.pformat(BuiltIn().get_variables()))
self.LOGGER.debug('attributes @ start suite: %s' % pprint.pformat(attributes))
但这是在日志输出:
2013-05-29 08:03:11,493 [51a618afdf08ff6296260098] DEBUG [NativeMethodAccessorImpl] - variables scoped at start suite: {'${outputdir}': u'/mypath/', '${outputfile}': 'NONE', '${reportfile}': 'NONE', '${none}': None, '${prevtestmessage}': '', '${suitemetadata}': {}, '${suitedocumentation}': '', '${\\n}': '\n', '${/}': '/', '${true}': True, '${:}': ':', '${suitesource}': u'/mypath/source', '${space}': ' ', u'${environment}': u'sit', '${suitename}': u'MySuite', '${debugfile}': 'NONE', '${null}': None, '${logfile}': 'NONE', '${prevteststatus}': '', '${tempdir}': u'/tmp', '${execdir}': u'mypath3', '${prevtestname}': '', '${false}': False, '@{empty}':(), '${empty}': ''}
2013-05-29 08:03:11,499 [51a618afdf08ff6296260098] DEBUG [NativeMethodAccessorImpl] - attributes @ start suite: {'doc': '',
'longname': u'BcvDocumentImageRequestTest',
'metadata': {},
'source': u'/robotRoot/MyTest',
'starttime': '20130529 08:03:11.224',
'suites': [u'MyTest', u'MyTest'],
'tests': [],
'totaltests': 2}
这将工作在Python/Jython 2.5.x上? – Ghasfarost
只要你有机器人框架在运行 – theheadofabroom
@Ghasfarost哦实际上 - 我不确定字典理解是否可以运行到2.6,但是经过一些调试进入我的测试用例后,我会看看我已经去了什么方式太麻烦了 - 我修改了答案 – theheadofabroom