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

Allow finer-grained testing of subprocess stderr. #6342

Merged
merged 2 commits into from
Mar 20, 2019

Conversation

cjerdonek
Copy link
Member

This PR adds expect_stderr_warning and expect_stderr_error arguments to PipTestEnvironment to permit finer-grained testing of stderr. It allows checking whether errors and warnings were logged in the subprocess, rather than simply checking whether stderr is non-empty.

This is most immediately to help with PR #6339.

@cjerdonek cjerdonek added C: tests Testing and related things skip news Does not need a NEWS file entry (eg: trivial changes) labels Mar 16, 2019
@cjerdonek cjerdonek force-pushed the test-subprocess-stderr branch 2 times, most recently from 428f0f3 to 7a6e1aa Compare March 16, 2019 10:59
@cjerdonek
Copy link
Member Author

cjerdonek commented Mar 16, 2019

Also, a benefit of this independent of PR #6339 is that in cases where we expect only a warning (e.g. deprecated Python versions), we can limit ourselves to being okay only with warnings and not also logged errors. In a subsequent PR, we can try making “expect_stderr” mean only “expect warning” and not “expect error.” This will make the tests more useful.

@cjerdonek cjerdonek added the type: enhancement Improvements to functionality label Mar 17, 2019
are weaker than errors.
"""
if expect_stderr_error:
expect_stderr_warning = True
Copy link
Member

Choose a reason for hiding this comment

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

Passing explicitely expect_stderr_warning=False, expect_stderr_error=True should raise then (and expect_stderr_warning should default to None, meaning either False or True depending on expect_stderr_error value)

@cjerdonek
Copy link
Member Author

cjerdonek commented Mar 20, 2019

Thanks, @xavfernandez. I incorporated the suggestion in your comment -- including adding a test case to check that the exception works. In the process of doing so, I also added a number of other test cases to check that various combinations of the arguments are working as intended.

Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@cjerdonek cjerdonek merged commit d3a5b58 into pypa:master Mar 20, 2019
@cjerdonek cjerdonek deleted the test-subprocess-stderr branch March 20, 2019 13:19
@lock
Copy link

lock bot commented May 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: tests Testing and related things skip news Does not need a NEWS file entry (eg: trivial changes) type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants