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
1=== modified file 'junitxml/__init__.py'
2--- junitxml/__init__.py 2011-12-07 16:54:18 +0000
3+++ junitxml/__init__.py 2013-10-28 14:04:16 +0000
4@@ -165,10 +165,11 @@
5 run.
6 """
7 duration = self._duration(self._run_start)
8- self._stream.write('<testsuite errors="%d" failures="%d" name="" '
9- 'tests="%d" time="%0.3f">\n' % (len(self.errors),
10+
11+ self._stream.write('<testsuite errors="%d" failures="%d"'
12+ ' skipped="%d" name="" tests="%d" time="%0.3f">\n' % (len(self.errors),
13 len(self.failures) + len(getattr(self, "unexpectedSuccesses", ())),
14- self.testsRun, duration))
15+ len(self.skipped), self.testsRun, duration))
16 self._stream.write(''.join(self._results))
17 self._stream.write('</testsuite>\n')
18
19
20=== modified file 'junitxml/tests/test_junitxml.py'
21--- junitxml/tests/test_junitxml.py 2011-12-07 16:54:18 +0000
22+++ junitxml/tests/test_junitxml.py 2013-10-28 14:04:16 +0000
23@@ -66,7 +66,7 @@
24 # Lose an hour (peeks inside, a little naughty but not very).
25 self.result.time(self.result._run_start - datetime.timedelta(0, 3600))
26 self.result.stopTestRun()
27- self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="0" time="0.000">
28+ self.assertEqual("""<testsuite errors="0" failures="0" skipped="0" name="" tests="0" time="0.000">
29 </testsuite>
30 """, self.get_output())
31
32@@ -80,7 +80,7 @@
33 # When stopTestRun is called, everything is output.
34 self.result.startTestRun()
35 self.result.stopTestRun()
36- self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="0" time="0.000">
37+ self.assertEqual("""<testsuite errors="0" failures="0" skipped="0" name="" tests="0" time="0.000">
38 </testsuite>
39 """, self.get_output())
40
41@@ -115,7 +115,7 @@
42 self.result.startTestRun()
43 Errors("test_me").run(self.result)
44 self.result.stopTestRun()
45- self.assertEqual("""<testsuite errors="1" failures="0" name="" tests="1" time="0.000">
46+ self.assertEqual("""<testsuite errors="1" failures="0" skipped="0" name="" tests="1" time="0.000">
47 <testcase classname="junitxml.tests.test_junitxml.Errors" name="test_me" time="0.000">
48 <error type="ZeroDivisionError">error</error>
49 </testcase>
50@@ -129,7 +129,7 @@
51 self.result.startTestRun()
52 Fails("test_me").run(self.result)
53 self.result.stopTestRun()
54- self.assertEqual("""<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
55+ self.assertEqual("""<testsuite errors="0" failures="1" skipped="0" name="" tests="1" time="0.000">
56 <testcase classname="junitxml.tests.test_junitxml.Fails" name="test_me" time="0.000">
57 <failure type="AssertionError">failure</failure>
58 </testcase>
59@@ -143,7 +143,7 @@
60 self.result.startTestRun()
61 Passes("test_me").run(self.result)
62 self.result.stopTestRun()
63- self.assertEqual("""<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
64+ self.assertEqual("""<testsuite errors="0" failures="0" skipped="0" name="" tests="1" time="0.000">
65 <testcase classname="junitxml.tests.test_junitxml.Passes" name="test_me" time="0.000"/>
66 </testsuite>
67 """, self.get_output())
68@@ -157,7 +157,7 @@
69 self.run_test_or_simulate(test, 'skipTest', self.result.addSkip, 'yo')
70 self.result.stopTestRun()
71 output = self.get_output()
72- expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
73+ expected = """<testsuite errors="0" failures="0" skipped="1" name="" tests="1" time="0.000">
74 <testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000">
75 <skipped>yo</skipped>
76 </testcase>
77@@ -177,13 +177,13 @@
78 Succeeds("test_me").run(self.result)
79 self.result.stopTestRun()
80 output = self.get_output()
81- expected = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
82+ expected = """<testsuite errors="0" failures="1" skipped="0" name="" tests="1" time="0.000">
83 <testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000">
84 <failure type="unittest.case._UnexpectedSuccess"/>
85 </testcase>
86 </testsuite>
87 """
88- expected_old = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
89+ expected_old = """<testsuite errors="0" failures="0" skipped="0" name="" tests="1" time="0.000">
90 <testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"/>
91 </testsuite>
92 """
93@@ -204,11 +204,11 @@
94 ExpectedFail("test_me").run(self.result)
95 self.result.stopTestRun()
96 output = self.get_output()
97- expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
98+ expected = """<testsuite errors="0" failures="0" skipped="0" name="" tests="1" time="0.000">
99 <testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000"/>
100 </testsuite>
101 """
102- expected_old = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
103+ expected_old = """<testsuite errors="0" failures="1" skipped="0" name="" tests="1" time="0.000">
104 <testcase classname="junitxml.tests.test_junitxml.ExpectedFail" name="test_me" time="0.000">
105 <failure type="AssertionError">failure</failure>
106 </testcase>

Subscribers

People subscribed via source and target branches

to all changes: