本文整理汇总了Python中nose.plugins.xunit.Xunit.addSuccess方法的典型用法代码示例。如果您正苦于以下问题:Python Xunit.addSuccess方法的具体用法?Python Xunit.addSuccess怎么用?Python Xunit.addSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.plugins.xunit.Xunit
的用法示例。
在下文中一共展示了Xunit.addSuccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestXMLOutputWithXML
# 需要导入模块: from nose.plugins.xunit import Xunit [as 别名]
# 或者: from nose.plugins.xunit.Xunit import addSuccess [as 别名]
#.........这里部分代码省略.........
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'], "1")
eq_(tree.attrib['failures'], "0")
eq_(tree.attrib['skip'], "0")
tc = tree.find("testcase")
eq_(tc.attrib['classname'], "test_xunit.TC")
eq_(tc.attrib['name'], "test_xunit.TC.runTest")
assert int(tc.attrib['time']) >= 0
err = tc.find("error")
eq_(err.attrib['type'], "exceptions.RuntimeError")
err_lines = err.text.strip().split("\n")
eq_(err_lines[0], 'Traceback (most recent call last):')
eq_(err_lines[-1], 'RuntimeError: some error happened')
eq_(err_lines[-2], ' raise RuntimeError("some error happened")')
else:
# this is a dumb test for 2.4-
assert '<?xml version="1.0" encoding="UTF-8"?>' in result
assert '<testsuite name="nosetests" tests="1" errors="1" failures="0" skip="0">' in result
assert '<testcase classname="test_xunit.TC" name="test_xunit.TC.runTest"' in result
assert '<error type="exceptions.RuntimeError">' in result
assert 'RuntimeError: some error happened' in result
assert '</error></testcase></testsuite>' in result
def test_addError_early(self):
test = mktest()
try:
raise RuntimeError("some error happened")
except RuntimeError:
some_err = sys.exc_info()
# 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")
eq_(tc.attrib['time'], "0")
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="test_xunit.TC.runTest" time="0">') in result
def test_addSuccess(self):
test = mktest()
self.x.startTest(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")
eq_(tree.attrib['failures'], "0")
eq_(tree.attrib['skip'], "0")
tc = tree.find("testcase")
eq_(tc.attrib['classname'], "test_xunit.TC")
eq_(tc.attrib['name'], "test_xunit.TC.runTest")
assert int(tc.attrib['time']) >= 0
else:
# this is a dumb test for 2.4-
assert '<?xml version="1.0" encoding="UTF-8"?>' in result
assert '<testsuite name="nosetests" tests="1" errors="0" failures="0" skip="0">' in result
assert '<testcase classname="test_xunit.TC" name="test_xunit.TC.runTest"' in result
assert '</testsuite>' in result
def test_addSuccess_early(self):
test = mktest()
# call addSuccess without startTest
# which can happen (?) -- did happen with JsLint plugin
self.x.addSuccess(test, (None,None,None))
result = self.get_xml_report()
print result
if self.ET:
tree = self.ET.fromstring(result)
tc = tree.find("testcase")
eq_(tc.attrib['time'], "0")
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="test_xunit.TC.runTest" time="0" />') in result
示例2: TestXMLOutputWithXML
# 需要导入模块: from nose.plugins.xunit import Xunit [as 别名]
# 或者: from nose.plugins.xunit.Xunit import addSuccess [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")
eq_(tree.attrib['failures'], "0")
eq_(tree.attrib['skip'], "0")
tc = tree.find("testcase")
eq_(tc.attrib['classname'], "test_xunit.TC")
eq_(tc.attrib['name'], "runTest")
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 '<testsuite name="nosetests" tests="1" errors="0" failures="0" skip="0">' in result
assert '<testcase classname="test_xunit.TC" name="runTest"' in result
assert '</testsuite>' in result
def test_addSuccess_early(self):
test = mktest()
# call addSuccess without startTest
# which can happen (?) -- did happen with JsLint plugin
self.x.addSuccess(test, (None,None,None))
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