-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libregrtest: junit-xml output doesn't support subTest #126237
Comments
@encukou do you already work on this? Or can I take this over, please? :) |
I just moved it out of my TODO list, thinking it might be fun for someone else :) |
What happens now for a test like this: def test_broken_subtest(self):
for x in [1, 2, 3]:
with self.subTest(x=x):
self.assertEqual(x, 0) produces: <testsuites tests="1" errors="0" failures="3"><testsuite start="2024-11-03 09:35:14.984110" tests="1" errors="0" failures="3"><testcase /></testsuite></testsuites> If we comment <testsuites tests="1" errors="0" failures="1"><testsuite start="2024-11-03 09:34:09.426455" tests="1" errors="0" failures="1"><testcase name="test.test_typing.TypeVarTests.test_broken_subtest" status="run" result="completed" time="0.002489"><system-out /><system-err /><failure type="AssertionError" message="AssertionError: 1 != 0 ">Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 58, in testPartExecutor
yield
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 660, in run
self._callTestMethod(testMethod)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 606, in _callTestMethod
result = method()
File "/Users/sobolev/Desktop/cpython2/Lib/test/test_typing.py", line 569, in test_broken_subtest
self.assertEqual(x, 0)
~~~~~~~~~~~~~~~~^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 916, in assertEqual
assertion_func(first, second, msg=msg)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 909, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 1 != 0
</failure></testcase></testsuite></testsuites> Basically, we need to have multiple |
I don't quite like that there are multiple <testsuites tests="1" errors="0" failures="3"><testsuite start="2024-11-03 14:20:57.276683" tests="1" errors="0" failures="3"><testcase name="test.test_typing.TypeVarTests.test_broken_subtest" status="run" result="completed" time="0.004247"><system-out /><system-err /><failure type="AssertionError" message="AssertionError: 1 != 0 ">Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 58, in testPartExecutor
yield
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 556, in subTest
yield
File "/Users/sobolev/Desktop/cpython2/Lib/test/test_typing.py", line 570, in test_broken_subtest
self.assertEqual(x, 0)
~~~~~~~~~~~~~~~~^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 916, in assertEqual
assertion_func(first, second, msg=msg)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 909, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 1 != 0
</failure><system-out /><system-err /><failure type="AssertionError" message="AssertionError: 2 != 0 ">Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 58, in testPartExecutor
yield
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 556, in subTest
yield
File "/Users/sobolev/Desktop/cpython2/Lib/test/test_typing.py", line 570, in test_broken_subtest
self.assertEqual(x, 0)
~~~~~~~~~~~~~~~~^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 916, in assertEqual
assertion_func(first, second, msg=msg)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 909, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 2 != 0
</failure><system-out /><system-err /><failure type="AssertionError" message="AssertionError: 3 != 0 ">Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 58, in testPartExecutor
yield
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 556, in subTest
yield
File "/Users/sobolev/Desktop/cpython2/Lib/test/test_typing.py", line 570, in test_broken_subtest
self.assertEqual(x, 0)
~~~~~~~~~~~~~~~~^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 916, in assertEqual
assertion_func(first, second, msg=msg)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/unittest/case.py", line 909, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 3 != 0
</failure></testcase></testsuite></testsuites> I think it would be hard to parse. Not sure that it is even supported. |
Running the tests with
--junit-xml
, the result does not includesubTest
results, asRegressionTestResult
inlibregrtest.testresult
does not implementaddSubTest
.There's no standard XML schema for the test results (see testmoapp/junitxml), but I think multiple
<error>
elements in a<testcase>
make senseThe text was updated successfully, but these errors were encountered: