Merge lp:~garyvdm/pyjunitxml/consistant_test_ids into lp:pyjunitxml

Proposed by Gary van der Merwe
Status: Needs review
Proposed branch: lp:~garyvdm/pyjunitxml/consistant_test_ids
Merge into: lp:pyjunitxml
Diff against target: 130 lines (+22/-14)
1 file modified
junitxml/tests/test_junitxml.py (+22/-14)
To merge this branch: bzr merge lp:~garyvdm/pyjunitxml/consistant_test_ids
Reviewer Review Type Date Requested Status
Robert Collins Needs Fixing
Martin Packman Needs Information
Review via email: mp+291497@code.launchpad.net

Description of the change

This fixes Bug #1491635.

I makes the test tests use a implementation of TestCase.id that is consistent across different python versions.

To post a comment you must log in.
Revision history for this message
Gary van der Merwe (garyvdm) wrote :

Sorry. I pushed using git-remote-bzr has not maintained commit ids. I will repush using bzr.

28. By Gary van der Merwe

For TestJUnitXmlResult use a TestCase.id implementation that is consistant accross different python versions.

Revision history for this message
Martin Packman (gz) wrote :

See inline comments.

review: Needs Information
Revision history for this message
Robert Collins (lifeless) :
review: Needs Fixing
Revision history for this message
Robert Collins (lifeless) wrote :

ping

Unmerged revisions

28. By Gary van der Merwe

For TestJUnitXmlResult use a TestCase.id implementation that is consistant accross different python versions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'junitxml/tests/test_junitxml.py'
2--- junitxml/tests/test_junitxml.py 2011-12-07 16:54:18 +0000
3+++ junitxml/tests/test_junitxml.py 2016-04-11 12:04:25 +0000
4@@ -32,6 +32,14 @@
5 def test_with_stream(self):
6 result = junitxml.JUnitXmlResult(StringIO())
7
8+class ConsistantIdTestCase(unittest.TestCase):
9+ """TestCase who's id is consistant accross python 2 & 3.
10+
11+ This is to fix https://bugs.launchpad.net/pyjunitxml/+bug/1491635
12+ """
13+
14+ def id(self):
15+ return "%s.%s" % (self.__class__.__name__, self._testMethodName)
16
17 class TestJUnitXmlResult(unittest.TestCase):
18
19@@ -109,47 +117,47 @@
20 self.assertTrue('Passes" name="test_me(version_1.6)"' in output)
21
22 def test_erroring_test(self):
23- class Errors(unittest.TestCase):
24+ class Errors(ConsistantIdTestCase):
25 def test_me(self):
26 1/0
27 self.result.startTestRun()
28 Errors("test_me").run(self.result)
29 self.result.stopTestRun()
30 self.assertEqual("""<testsuite errors="1" failures="0" name="" tests="1" time="0.000">
31-<testcase classname="junitxml.tests.test_junitxml.Errors" name="test_me" time="0.000">
32+<testcase classname="Errors" name="test_me" time="0.000">
33 <error type="ZeroDivisionError">error</error>
34 </testcase>
35 </testsuite>
36 """, self.get_output())
37
38 def test_failing_test(self):
39- class Fails(unittest.TestCase):
40+ class Fails(ConsistantIdTestCase):
41 def test_me(self):
42 self.fail()
43 self.result.startTestRun()
44 Fails("test_me").run(self.result)
45 self.result.stopTestRun()
46 self.assertEqual("""<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
47-<testcase classname="junitxml.tests.test_junitxml.Fails" name="test_me" time="0.000">
48+<testcase classname="Fails" name="test_me" time="0.000">
49 <failure type="AssertionError">failure</failure>
50 </testcase>
51 </testsuite>
52 """, self.get_output())
53
54 def test_successful_test(self):
55- class Passes(unittest.TestCase):
56+ class Passes(ConsistantIdTestCase):
57 def test_me(self):
58 pass
59 self.result.startTestRun()
60 Passes("test_me").run(self.result)
61 self.result.stopTestRun()
62 self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
63-<testcase classname="junitxml.tests.test_junitxml.Passes" name="test_me" time="0.000"/>
64+<testcase classname="Passes" name="test_me" time="0.000"/>
65 </testsuite>
66 """, self.get_output())
67
68 def test_skip_test(self):
69- class Skips(unittest.TestCase):
70+ class Skips(ConsistantIdTestCase):
71 def test_me(self):
72 self.skipTest("yo")
73 self.result.startTestRun()
74@@ -158,7 +166,7 @@
75 self.result.stopTestRun()
76 output = self.get_output()
77 expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
78-<testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000">
79+<testcase classname="Skips" name="test_me" time="0.000">
80 <skipped>yo</skipped>
81 </testcase>
82 </testsuite>
83@@ -166,7 +174,7 @@
84 self.assertEqual(expected, output)
85
86 def test_unexpected_success_test(self):
87- class Succeeds(unittest.TestCase):
88+ class Succeeds(ConsistantIdTestCase):
89 def test_me(self):
90 pass
91 try:
92@@ -178,13 +186,13 @@
93 self.result.stopTestRun()
94 output = self.get_output()
95 expected = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
96-<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000">
97+<testcase classname="Succeeds" name="test_me" time="0.000">
98 <failure type="unittest.case._UnexpectedSuccess"/>
99 </testcase>
100 </testsuite>
101 """
102 expected_old = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
103-<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"/>
104+<testcase classname="Succeeds" name="test_me" time="0.000"/>
105 </testsuite>
106 """
107 if output != expected_old:
108@@ -192,7 +200,7 @@
109
110 def test_expected_failure_test(self):
111 expected_failure_support = [True]
112- class ExpectedFail(unittest.TestCase):
113+ class ExpectedFail(ConsistantIdTestCase):
114 def test_me(self):
115 self.fail("fail")
116 try:
117@@ -205,11 +213,11 @@
118 self.result.stopTestRun()
119 output = self.get_output()
120 expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
121-<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000"/>
122+<testcase classname="ExpectedFail" name="test_me" time="0.000"/>
123 </testsuite>
124 """
125 expected_old = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
126-<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000">
127+<testcase classname="ExpectedFail" name="test_me" time="0.000">
128 <failure type="AssertionError">failure</failure>
129 </testcase>
130 </testsuite>

Subscribers

People subscribed via source and target branches