Merge lp:~joetalbott/pyjunitxml/add_skipped_count into lp:pyjunitxml

Proposed by Joe Talbott
Status: Needs review
Proposed branch: lp:~joetalbott/pyjunitxml/add_skipped_count
Merge into: lp:pyjunitxml
Diff against target: 106 lines (+14/-13)
2 files modified
junitxml/__init__.py (+4/-3)
junitxml/tests/test_junitxml.py (+10/-10)
To merge this branch: bzr merge lp:~joetalbott/pyjunitxml/add_skipped_count
Reviewer Review Type Date Requested Status
Joe Talbott (community) Needs Resubmitting
Robert Collins Needs Fixing
Review via email: mp+192604@code.launchpad.net

Commit message

Add "skipped=" section to results if testcases were skipped.

Fixes: https://bugs.launchpad.net/pyjunitxml/+bug/1243928

Description of the change

Add "skipped=" section to results if testcases were skipped.

Fixes: https://bugs.launchpad.net/pyjunitxml/+bug/1243928

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

As commented on the bug, it seems that skipped tests are supported by the format but nobody ever decided to specify the testsuite attribute.

There is even conflicting implementations that use either 'skips=' or 'skipped='...

Revision history for this message
Robert Collins (lifeless) wrote :

Please follow the style of other attributes there - just always include the attribute - much simpler, less to go wrong, and it will let people see what to look for in parsers without having to guess.

review: Needs Fixing
29. By Joe Talbott

Always show skipped testcase summary.

Revision history for this message
Joe Talbott (joetalbott) :
review: Needs Resubmitting

Unmerged revisions

29. By Joe Talbott

Always show skipped testcase summary.

28. By Joe Talbott

Add "skipped=" section to results if testcases were skipped.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'junitxml/__init__.py'
--- junitxml/__init__.py 2011-12-07 16:54:18 +0000
+++ junitxml/__init__.py 2013-10-28 14:04:16 +0000
@@ -165,10 +165,11 @@
165 run.165 run.
166 """166 """
167 duration = self._duration(self._run_start)167 duration = self._duration(self._run_start)
168 self._stream.write('<testsuite errors="%d" failures="%d" name="" '168
169 'tests="%d" time="%0.3f">\n' % (len(self.errors),169 self._stream.write('<testsuite errors="%d" failures="%d"'
170 ' skipped="%d" name="" tests="%d" time="%0.3f">\n' % (len(self.errors),
170 len(self.failures) + len(getattr(self, "unexpectedSuccesses", ())),171 len(self.failures) + len(getattr(self, "unexpectedSuccesses", ())),
171 self.testsRun, duration))172 len(self.skipped), self.testsRun, duration))
172 self._stream.write(''.join(self._results))173 self._stream.write(''.join(self._results))
173 self._stream.write('</testsuite>\n')174 self._stream.write('</testsuite>\n')
174175
175176
=== modified file 'junitxml/tests/test_junitxml.py'
--- junitxml/tests/test_junitxml.py 2011-12-07 16:54:18 +0000
+++ junitxml/tests/test_junitxml.py 2013-10-28 14:04:16 +0000
@@ -66,7 +66,7 @@
66 # Lose an hour (peeks inside, a little naughty but not very).66 # Lose an hour (peeks inside, a little naughty but not very).
67 self.result.time(self.result._run_start - datetime.timedelta(0, 3600))67 self.result.time(self.result._run_start - datetime.timedelta(0, 3600))
68 self.result.stopTestRun()68 self.result.stopTestRun()
69 self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="0" time="0.000">69 self.assertEqual("""<testsuite errors="0" failures="0" skipped="0" name="" tests="0" time="0.000">
70</testsuite>70</testsuite>
71""", self.get_output())71""", self.get_output())
7272
@@ -80,7 +80,7 @@
80 # When stopTestRun is called, everything is output.80 # When stopTestRun is called, everything is output.
81 self.result.startTestRun()81 self.result.startTestRun()
82 self.result.stopTestRun()82 self.result.stopTestRun()
83 self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="0" time="0.000">83 self.assertEqual("""<testsuite errors="0" failures="0" skipped="0" name="" tests="0" time="0.000">
84</testsuite>84</testsuite>
85""", self.get_output())85""", self.get_output())
8686
@@ -115,7 +115,7 @@
115 self.result.startTestRun()115 self.result.startTestRun()
116 Errors("test_me").run(self.result)116 Errors("test_me").run(self.result)
117 self.result.stopTestRun()117 self.result.stopTestRun()
118 self.assertEqual("""<testsuite errors="1" failures="0" name="" tests="1" time="0.000">118 self.assertEqual("""<testsuite errors="1" failures="0" skipped="0" name="" tests="1" time="0.000">
119<testcase classname="junitxml.tests.test_junitxml.Errors" name="test_me" time="0.000">119<testcase classname="junitxml.tests.test_junitxml.Errors" name="test_me" time="0.000">
120<error type="ZeroDivisionError">error</error>120<error type="ZeroDivisionError">error</error>
121</testcase>121</testcase>
@@ -129,7 +129,7 @@
129 self.result.startTestRun()129 self.result.startTestRun()
130 Fails("test_me").run(self.result)130 Fails("test_me").run(self.result)
131 self.result.stopTestRun()131 self.result.stopTestRun()
132 self.assertEqual("""<testsuite errors="0" failures="1" name="" tests="1" time="0.000">132 self.assertEqual("""<testsuite errors="0" failures="1" skipped="0" name="" tests="1" time="0.000">
133<testcase classname="junitxml.tests.test_junitxml.Fails" name="test_me" time="0.000">133<testcase classname="junitxml.tests.test_junitxml.Fails" name="test_me" time="0.000">
134<failure type="AssertionError">failure</failure>134<failure type="AssertionError">failure</failure>
135</testcase>135</testcase>
@@ -143,7 +143,7 @@
143 self.result.startTestRun()143 self.result.startTestRun()
144 Passes("test_me").run(self.result)144 Passes("test_me").run(self.result)
145 self.result.stopTestRun()145 self.result.stopTestRun()
146 self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="1" time="0.000">146 self.assertEqual("""<testsuite errors="0" failures="0" skipped="0" name="" tests="1" time="0.000">
147<testcase classname="junitxml.tests.test_junitxml.Passes" name="test_me" time="0.000"/>147<testcase classname="junitxml.tests.test_junitxml.Passes" name="test_me" time="0.000"/>
148</testsuite>148</testsuite>
149""", self.get_output())149""", self.get_output())
@@ -157,7 +157,7 @@
157 self.run_test_or_simulate(test, 'skipTest', self.result.addSkip, 'yo')157 self.run_test_or_simulate(test, 'skipTest', self.result.addSkip, 'yo')
158 self.result.stopTestRun()158 self.result.stopTestRun()
159 output = self.get_output()159 output = self.get_output()
160 expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">160 expected = """<testsuite errors="0" failures="0" skipped="1" name="" tests="1" time="0.000">
161<testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000">161<testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000">
162<skipped>yo</skipped>162<skipped>yo</skipped>
163</testcase>163</testcase>
@@ -177,13 +177,13 @@
177 Succeeds("test_me").run(self.result)177 Succeeds("test_me").run(self.result)
178 self.result.stopTestRun()178 self.result.stopTestRun()
179 output = self.get_output()179 output = self.get_output()
180 expected = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">180 expected = """<testsuite errors="0" failures="1" skipped="0" name="" tests="1" time="0.000">
181<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000">181<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000">
182<failure type="unittest.case._UnexpectedSuccess"/>182<failure type="unittest.case._UnexpectedSuccess"/>
183</testcase>183</testcase>
184</testsuite>184</testsuite>
185"""185"""
186 expected_old = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">186 expected_old = """<testsuite errors="0" failures="0" skipped="0" name="" tests="1" time="0.000">
187<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"/>187<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"/>
188</testsuite>188</testsuite>
189"""189"""
@@ -204,11 +204,11 @@
204 ExpectedFail("test_me").run(self.result)204 ExpectedFail("test_me").run(self.result)
205 self.result.stopTestRun()205 self.result.stopTestRun()
206 output = self.get_output()206 output = self.get_output()
207 expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">207 expected = """<testsuite errors="0" failures="0" skipped="0" name="" tests="1" time="0.000">
208<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000"/>208<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000"/>
209</testsuite>209</testsuite>
210"""210"""
211 expected_old = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">211 expected_old = """<testsuite errors="0" failures="1" skipped="0" name="" tests="1" time="0.000">
212<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000">212<testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000">
213<failure type="AssertionError">failure</failure>213<failure type="AssertionError">failure</failure>
214</testcase>214</testcase>

Subscribers

People subscribed via source and target branches

to all changes: