diff options
Diffstat (limited to 'unit_tests')
-rw-r--r-- | unit_tests/test_xunit.py | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/unit_tests/test_xunit.py b/unit_tests/test_xunit.py index dd54b8d..dc25599 100644 --- a/unit_tests/test_xunit.py +++ b/unit_tests/test_xunit.py @@ -95,19 +95,32 @@ class TestTee(unittest.TestCase): class TestXMLOutputWithXML(unittest.TestCase): + def test_prefix_from_environ(self): + parser = optparse.OptionParser() + x = Xunit() + x.add_options(parser, env={'NOSE_XUNIT_PREFIX_WITH_TESTSUITE_NAME': 'true'}) + (options, args) = parser.parse_args([]) + eq_(options.xunit_prefix_class, True) + + def test_prefix_from_opt(self): + parser = optparse.OptionParser() + x = Xunit() + x.add_options(parser, env={}) + (options, args) = parser.parse_args(["--xunit-prefix-with-testsuite-name"]) + eq_(options.xunit_prefix_class, True) + +class BaseTestXMLOutputWithXML(unittest.TestCase): + def configure(self, args): + parser = optparse.OptionParser() + self.x.add_options(parser, env={}) + (options, args) = parser.parse_args(args) + self.x.configure(options, Config()) def setUp(self): self.xmlfile = os.path.abspath( os.path.join(os.path.dirname(__file__), 'support', 'xunit.xml')) - parser = optparse.OptionParser() self.x = Xunit() - self.x.add_options(parser, env={}) - (options, args) = parser.parse_args([ - "--with-xunit", - "--xunit-file=%s" % self.xmlfile - ]) - self.x.configure(options, Config()) try: import xml.etree.ElementTree @@ -128,6 +141,39 @@ class TestXMLOutputWithXML(unittest.TestCase): f.close() return data +class TestXMLOutputWithXMLAndPrefix(BaseTestXMLOutputWithXML): + def setUp(self): + super(TestXMLOutputWithXMLAndPrefix, self).setUp() + self.configure([ + "--with-xunit", + "--xunit-file=%s" % self.xmlfile, + "--xunit-prefix-with-testsuite-name" + ]) + + 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) + tc = tree.find("testcase") + eq_(tc.attrib['classname'], "nosetests.test_xunit.TC") + else: + # this is a dumb test for 2.4- + assert '<testcase classname="nosetests.test_xunit.TC" name="runTest"' in result + +class TestXMLOutputWithXML(BaseTestXMLOutputWithXML): + def setUp(self): + super(TestXMLOutputWithXML, self).setUp() + self.configure([ + "--with-xunit", + "--xunit-file=%s" % self.xmlfile + ]) + def test_addFailure(self): test = mktest() self.x.beforeTest(test) |