Skip to content
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

Reduce test spam by using unittest output buffering #825

Merged
merged 1 commit into from
Feb 20, 2019
Merged

Conversation

awwad
Copy link
Contributor

@awwad awwad commented Feb 19, 2019

Thanks go to @lukpueh for this helpful tip.

This is a succinct replacement for PR #819.

After merge, stdout from the code being tested should only appear if the test has failed or errored out.

This functionality is provided by unittest.TextTestRunner argument buffer=True.
This functions like the --buffer command line argument listed here

Thanks go to @lukpueh for this helpful tip.

After merge, stdout should only appear if a test has failed. This
functionality is provided by `unittest.TextTestRunner` argument `buffer=True`.
This functions like the `--buffer` command line argument listed here:
https://docs.python.org/3/library/unittest.html#command-line-options

std out is discarded if a test succeeds.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the patch... :)

Please fix travis py27 build failure before merging though. I don't think it is related to your changes, unless Python2's SimpleHttp, from which the failure seems to stem, does not like unittest's standard stream overriding? OTOH, the tests pass locally on my machine.

I'm also linking our discussion from in-toto/in-toto#240. It might be helpful if you ever come back here, e.g. because you want to enhance unittest output.

@awwad
Copy link
Contributor Author

awwad commented Feb 20, 2019

I looked over it, and I ran it again and it passed. Usually, the cause of something like the error there is an inadequate delay to let the http/s server or (in this case) proxy start up. In this case, though, the delay of 4s seems like plenty. I've also seen rare port collisions, but that's already corrected for here (unless multiple test modules are running in parallel for some reason, perhaps). The proxy may not have been ready, or some other issue may have occurred with the proxy server startup. I'm going to tolerate low rates of test failures if they occur due to a test proxy connection issue (and succeed when re-run).

@awwad awwad merged commit 1fc7da7 into develop Feb 20, 2019
@awwad awwad deleted the quieter_tests_2 branch April 1, 2019 20:01
@awwad awwad restored the quieter_tests_2 branch April 1, 2019 20:01
@awwad awwad deleted the quieter_tests_2 branch April 1, 2019 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants