Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
python-junitxml
junitxml-tests.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File junitxml-tests.patch of Package python-junitxml
Index: junitxml-0.7/junitxml/tests/test_junitxml.py =================================================================== --- junitxml-0.7.orig/junitxml/tests/test_junitxml.py +++ junitxml-0.7/junitxml/tests/test_junitxml.py @@ -32,6 +32,14 @@ class TestJUnitXmlResult__init__(unittes def test_with_stream(self): result = junitxml.JUnitXmlResult(StringIO()) +class ConsistantIdTestCase(unittest.TestCase): + """TestCase who's id is consistant accross python 2 & 3. + + This is to fix https://bugs.launchpad.net/pyjunitxml/+bug/1491635 + """ + + def id(self): + return "%s.%s" % (self.__class__.__name__, self._testMethodName) class TestJUnitXmlResult(unittest.TestCase): @@ -47,16 +55,6 @@ class TestJUnitXmlResult(unittest.TestCa r'(?s)<error (.*?)>.*?</error>', r'<error \1>error</error>', re.sub(r'time="\d+\.\d+"', 'time="0.000"', output))) - def run_test_or_simulate(self, test, method_name, manual_method, - *manual_args): - if getattr(test, method_name, None): - test.run(self.result) - else: - # older python - manually execute - self.result.startTest(test) - manual_method(test, *manual_args) - self.result.stopTest(test) - def test_run_duration_handles_datestamping_in_the_past(self): # When used via subunit2junitxml, startTestRun is called before # any tz info in the test stream has been seen. @@ -109,64 +107,47 @@ class TestJUnitXmlResult(unittest.TestCa self.assertTrue('Passes" name="test_me(version_1.6)"' in output) def test_erroring_test(self): - class Errors(unittest.TestCase): + class Errors(ConsistantIdTestCase): def test_me(self): 1/0 self.result.startTestRun() Errors("test_me").run(self.result) self.result.stopTestRun() self.assertEqual("""<testsuite errors="1" failures="0" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.Errors" name="test_me" time="0.000"> +<testcase classname="Errors" name="test_me" time="0.000"> <error type="ZeroDivisionError">error</error> </testcase> </testsuite> """, self.get_output()) def test_failing_test(self): - class Fails(unittest.TestCase): + class Fails(ConsistantIdTestCase): def test_me(self): self.fail() self.result.startTestRun() Fails("test_me").run(self.result) self.result.stopTestRun() self.assertEqual("""<testsuite errors="0" failures="1" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.Fails" name="test_me" time="0.000"> +<testcase classname="Fails" name="test_me" time="0.000"> <failure type="AssertionError">failure</failure> </testcase> </testsuite> """, self.get_output()) def test_successful_test(self): - class Passes(unittest.TestCase): + class Passes(ConsistantIdTestCase): def test_me(self): pass self.result.startTestRun() Passes("test_me").run(self.result) self.result.stopTestRun() self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.Passes" name="test_me" time="0.000"/> +<testcase classname="Passes" name="test_me" time="0.000"/> </testsuite> """, self.get_output()) - def test_skip_test(self): - class Skips(unittest.TestCase): - def test_me(self): - self.skipTest("yo") - self.result.startTestRun() - test = Skips("test_me") - self.run_test_or_simulate(test, 'skipTest', self.result.addSkip, 'yo') - self.result.stopTestRun() - output = self.get_output() - expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000"> -<skipped>yo</skipped> -</testcase> -</testsuite> -""" - self.assertEqual(expected, output) - def test_unexpected_success_test(self): - class Succeeds(unittest.TestCase): + class Succeeds(ConsistantIdTestCase): def test_me(self): pass try: @@ -178,13 +159,13 @@ class TestJUnitXmlResult(unittest.TestCa self.result.stopTestRun() output = self.get_output() expected = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"> +<testcase classname="Succeeds" name="test_me" time="0.000"> <failure type="unittest.case._UnexpectedSuccess"/> </testcase> </testsuite> """ expected_old = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"/> +<testcase classname="Succeeds" name="test_me" time="0.000"/> </testsuite> """ if output != expected_old: @@ -192,7 +173,7 @@ class TestJUnitXmlResult(unittest.TestCa def test_expected_failure_test(self): expected_failure_support = [True] - class ExpectedFail(unittest.TestCase): + class ExpectedFail(ConsistantIdTestCase): def test_me(self): self.fail("fail") try: @@ -205,11 +186,11 @@ class TestJUnitXmlResult(unittest.TestCa self.result.stopTestRun() output = self.get_output() expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000"/> +<testcase classname="ExpectedFail" name="test_me" time="0.000"/> </testsuite> """ expected_old = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000"> -<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000"> +<testcase classname="ExpectedFail" name="test_me" time="0.000"> <failure type="AssertionError">failure</failure> </testcase> </testsuite>
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor