Pip: Make PipTestEnvironment stderr checks more assertive

Created on 14 Aug 2019  路  9Comments  路  Source: pypa/pip

We can tighten the tests in the following way. Rename the PipTestEnvironment.run() arguments of allow_stderr_warning and allow_stderr_error arguments to expect_stderr_warning and expect_stderr_error:

https://github.com/pypa/pip/blob/2bfafc9b70f76ec0b019c96311cb437e739b21e2/tests/lib/__init__.py#L501-L507

and make the test fail if the argument is passed and a warning or error isn't present, respectively. The idea is that the argument should only be passed if it's actually needed, unlike the current case where the test is passing if the argument is provided unnecessarily.

Also, to do this it might be necessary to do a check of some kind to know if the argument should be passed. For example, whether a deprecation warning is emitted can depend on what version is running.

_Posted in its original form by @cjerdonek in #161 (comment)_

tests awaiting PR maintenance

Most helpful comment

Hey @ssurbhi560. Thanks for pinging me! Can't really find a time to get this done. Would you like to pick it up? Please, feel free to 馃檹

All 9 comments

A related task is to remove the expect_stderr argument since it's redundant with allow_stderr_warning.

Hello @cjerdonek,

Could you help me to clarify a few cases?

Cases for expect_stderr_warning=True

run(command, expect_stderr_warning=True)
  1. if a command produces no stderr
    ... then raises a RuntimeError("expect a warning")
  2. if a command produces stderr: "WARNING: Hello, world!"
    ... then nothing raises
  3. if a command produces stderr: "ERROR: Hello, world!"
    ... then raises a RuntimeError("expect a warning")

Cases for expect_stderr_error=True

run(command, expect_stderr_error=True)
  1. if a command produces no stderr
    ... then raises a RuntimeError("expect an error")
  2. if a command produces stderr: "WARNING: Hello, world!"
    ... then raises a RuntimeError("expect an error")
  3. if a command produces stderr: "ERROR: Hello, world!"
    ... then nothing raises

Questions:

  • Are these statements true?
  • Should expect_stderr_error=True imply expect_stderr_warning=True?

My answers:

  • Yes.
  • No, it should require that.

Hey @atugushev , can I please take your work further and work on this issue, if you are not onto this anymore? :-)

Hey @ssurbhi560. Thanks for pinging me! Can't really find a time to get this done. Would you like to pick it up? Please, feel free to 馃檹

@atugushev , I would be glad to pick it up and take this further.
Thank you ! :)

Hey @ssurbhi560 are you working over it? If not, then I'd like to take up this issue. :)

Hey @gutsytechster! I won't be able to work on this right now, feel free to work on it. :)

Here, does it mean that for an error to be expected to raise, the variables expect_stderr_error and expect_stderr_warning would be both True? However, in case of an expected warning, only expect_stderr_warning would be True but not expect_stderr_error.

Was this page helpful?
0 / 5 - 0 ratings