-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-34945: Buffer output in test suite only when creating junit file #10204
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
Conversation
Lib/test/support/testresult.py
Outdated
ET.SubElement(e, 'system-out').text = stdout | ||
stderr = self._stderr_buffer.getvalue().rstrip() | ||
ET.SubElement(e, 'system-err').text = stderr | ||
if self._stderr_buffer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stdout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups! I forgot to add that file when pushing the latest fix
After commit d0f49d2, the output of the test suite is always buffered as the test output needs to be included in the JUnit file in same cases (as when a test fails). This has the consequence that printing or using debuggers (like pdb) in the test suite does not result in a good user experience anymore. This commit modifies the test suite runner so it only captures the test output when the JUnit file is requested to fix the regression so prints and debuggers are usable again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work for me: I don't see my print(). It works before the JUnit change.
vstinner@apu$ ./python -m test test_os
Run tests sequentially
0:00:00 load avg: 0.34 [1/1] test_os
git dif
== Tests result: SUCCESS ==
1 test OK.
Total duration: 1 sec 436 ms
Tests result: SUCCESS
vstinner@apu$ git diff
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 3f6e48f0c8..716b079a21 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -99,6 +99,7 @@ class FileTests(unittest.TestCase):
def test_access(self):
f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
+ print("test_access")
os.close(f)
self.assertTrue(os.access(support.TESTFN, os.W_OK))
When you're done making the requested changes, leave the comment: |
@vstinner Can your run it in verbose mode?
|
This is because the JUnit change made this choice: cpython/Lib/test/support/testresult.py Line 170 in 8f094a7
|
I would like to get back the old behavior: see my print() without -v. The commit d0f49d2 changed the behavior and it wasn't the intent of Steve Dower. |
I have made the requested changes; please review again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The functional test now works as expected: adding print("XXX") now displays XXX in stdout ;-)
Just a minor suggestion.
Lib/test/support/testresult.py
Outdated
ET.SubElement(e, 'system-out').text = stdout | ||
stderr = self._stderr_buffer.getvalue().rstrip() | ||
ET.SubElement(e, 'system-err').text = stderr | ||
if self._stdout_buffer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use "is not None"?
Since JUnit has been added to other branches, this change should be ported to other branches, no? |
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
…ythonGH-10204) After commit d0f49d2, the output of the test suite is always buffered as the test output needs to be included in the JUnit file in same cases (as when a test fails). This has the consequence that printing or using debuggers (like pdb) in the test suite does not result in a good user experience anymore. This commit modifies the test suite runner so it only captures the test output when the JUnit file is requested to fix the regression so prints and debuggers are usable again. (cherry picked from commit 0227748) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
GH-10227 is a backport of this pull request to the 3.7 branch. |
…ythonGH-10204) After commit d0f49d2, the output of the test suite is always buffered as the test output needs to be included in the JUnit file in same cases (as when a test fails). This has the consequence that printing or using debuggers (like pdb) in the test suite does not result in a good user experience anymore. This commit modifies the test suite runner so it only captures the test output when the JUnit file is requested to fix the regression so prints and debuggers are usable again. (cherry picked from commit 0227748) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
GH-10228 is a backport of this pull request to the 3.6 branch. |
…H-10204) After commit d0f49d2, the output of the test suite is always buffered as the test output needs to be included in the JUnit file in same cases (as when a test fails). This has the consequence that printing or using debuggers (like pdb) in the test suite does not result in a good user experience anymore. This commit modifies the test suite runner so it only captures the test output when the JUnit file is requested to fix the regression so prints and debuggers are usable again. (cherry picked from commit 0227748) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
…H-10204) After commit d0f49d2, the output of the test suite is always buffered as the test output needs to be included in the JUnit file in same cases (as when a test fails). This has the consequence that printing or using debuggers (like pdb) in the test suite does not result in a good user experience anymore. This commit modifies the test suite runner so it only captures the test output when the JUnit file is requested to fix the regression so prints and debuggers are usable again. (cherry picked from commit 0227748) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
After commit d0f49d2, the output of the
test suite is always buffered as the test output needs to be included in
the JUnit file in same cases (as when a test fails). This has the
consequence that printing or using debuggers (like pdb) in the test
suite does not result in a good user experience anymore.
This commit modifies the test suite runner so it only captures the test
output when the JUnit file is requested to fix the regression so prints
and debuggers are usable again.
CC: @matrixise
https://bugs.python.org/issue34945