本文整理匯總了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")