本文整理汇总了Python中nose.plugins.xunit.Xunit.startContext方法的典型用法代码示例。如果您正苦于以下问题:Python Xunit.startContext方法的具体用法?Python Xunit.startContext怎么用?Python Xunit.startContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.plugins.xunit.Xunit
的用法示例。
在下文中一共展示了Xunit.startContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestXMLOutputWithXML
# 需要导入模块: from nose.plugins.xunit import Xunit [as 别名]
# 或者: from nose.plugins.xunit.Xunit import startContext [as 别名]
#.........这里部分代码省略.........
def test_non_utf8_error(self):
# See http://code.google.com/p/python-nose/issues/detail?id=395
test = mktest()
self.x.beforeTest(test)
try:
raise RuntimeError(chr(128)) # cannot encode as utf8
except RuntimeError:
some_err = sys.exc_info()
self.x.addError(test, some_err)
result = self.get_xml_report()
print repr(result)
if self.ET:
tree = self.ET.fromstring(result)
tc = tree.find("testcase")
err = tc.find("error")
if UNICODE_STRINGS:
eq_(err.attrib['message'],
'\x80')
else:
eq_(err.attrib['message'],
u'\ufffd')
else:
# this is a dumb test for 2.4-
assert 'RuntimeError: \xef\xbf\xbd' in result
def test_addError_early(self):
test = mktest()
try:
raise RuntimeError("some error happened")
except RuntimeError:
some_err = sys.exc_info()
self.x.startContext(None)
# call addError without startTest
# which can happen if setup() raises an error
self.x.addError(test, some_err)
result = self.get_xml_report()
print result
if self.ET:
tree = self.ET.fromstring(result)
tc = tree.find("testcase")
assert time_taken.match(tc.attrib['time']), (
'Expected decimal time: %s' % tc.attrib['time'])
else:
# this is a dumb test for 2.4-
assert '<?xml version="1.0" encoding="UTF-8"?>' in result
assert ('<testcase classname="test_xunit.TC" '
'name="runTest" time="0') in result
def test_addSuccess(self):
test = mktest()
self.x.beforeTest(test)
self.x.addSuccess(test, (None,None,None))
result = self.get_xml_report()
print result
if self.ET:
tree = self.ET.fromstring(result)
eq_(tree.attrib['name'], "nosetests")
eq_(tree.attrib['tests'], "1")
eq_(tree.attrib['errors'], "0")