Skip to content

bpo-33746: Fix test_unittest when run in verbose mode #7799

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

Merged
merged 2 commits into from
Jun 20, 2018
Merged

bpo-33746: Fix test_unittest when run in verbose mode #7799

merged 2 commits into from
Jun 20, 2018

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 19, 2018

Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.

support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".

Call also removeResult() to restore unittest.signals._results to
avoid side effect of the test.

https://bugs.python.org/issue33746

Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.

support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".

Call also removeResult() to restore unittest.signals._results to
avoid side effect of the test.
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM!

Added a tiny suggestion.

self.fail("result not found")

try:
self.assertIn(result, unittest.signals._results)
Copy link
Member

Choose a reason for hiding this comment

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

I would add self.assertNotIn(result, unittest.signals._results) just before unittest.registerResult(result).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Test also assertNotIn() before registerResult().
@vstinner vstinner merged commit fd8fbce into python:master Jun 20, 2018
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@vstinner vstinner deleted the fix_unittest_verbose branch June 20, 2018 09:29
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 20, 2018
…thonGH-7799)

Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.

support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".

Call also removeResult() to restore unittest.signals._results to
avoid test side effect.
(cherry picked from commit fd8fbce)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

GH-7820 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 20, 2018
…thonGH-7799)

Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.

support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".

Call also removeResult() to restore unittest.signals._results to
avoid test side effect.
(cherry picked from commit fd8fbce)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

GH-7821 is a backport of this pull request to the 3.6 branch.

miss-islington added a commit that referenced this pull request Jun 20, 2018
…-7799)

Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.

support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".

Call also removeResult() to restore unittest.signals._results to
avoid test side effect.
(cherry picked from commit fd8fbce)

Co-authored-by: Victor Stinner <[email protected]>
miss-islington added a commit that referenced this pull request Jun 20, 2018
…-7799)

Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.

support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".

Call also removeResult() to restore unittest.signals._results to
avoid test side effect.
(cherry picked from commit fd8fbce)

Co-authored-by: Victor Stinner <[email protected]>
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.

5 participants