Pytest: UsageError raised when specifying config override options followed by test path(s)

Created on 10 Jan 2018  路  8Comments  路  Source: pytest-dev/pytest

Summary

When using -o or --override-ini followed by one or more test paths, the session terminates with "ERROR: -o/--override-ini expects option=value style."

pipenv graph

pytest==3.3.2
  - attrs [required: >=17.2.0, installed: 17.4.0]
  - pluggy [required: <0.7,>=0.5, installed: 0.6.0]
  - py [required: >=1.5.0, installed: 1.5.2]
  - setuptools [required: Any, installed: 38.2.5]
  - six [required: >=1.10.0, installed: 1.11.0]

Operating System:

macOS High Sierra 10.13.2

Example:

$ pytest -o console_output_style=classic test.py
ERROR: -o/--override-ini expects option=value style.

The relevant code is below. I would suggest that we only raise the exception if the first value does not contain an '=', and stop considering values as overrides as soon as they no longer contain the character.

https://github.com/pytest-dev/pytest/blob/cf9b31bd5adf1eb947af4f863ce3bca4d4cf5bec/_pytest/config.py#L1188-L1202

easy config bug

Most helpful comment

Sorry @wagnerluis1982 this was already resolved by #3147

All 8 comments

GitMate.io thinks the contributor most likely able to help you is @nicoddemus.

. I would suggest that we only raise the exception if the first value does not contain an '=', and stop considering values as overrides as soon as they no longer contain the character.

Sounds reasonable, thanks @davehunt!

Hi @davehunt, @nicoddemus
I can take a look at this if there is no work already underway?
I am a first time contributor

@arcoyle thanks, we appreciate! Please go ahead! 馃榿

If you get stuck, feel free to open a PR anyway so we can help out over the code you managed to do so far.

@nicoddemus I have opened a PR for this issue, could you please review.

One thing I noticed while testing was the use of switch options before the test path stops the exception. Nothing is added to the list of key value pairs after the switch option.
For example if I take out the fix and run the test with a -o console_output_style=classic -s test.py it won't raise the exception.
This is because of how the argparse module behaves. Just thought it would be interesting to note as it could cause some tests to mask the issue.

Hi, I'd love to contribute to pytest.

My first contribution is checking if this issue is still relevant :smile:. In my machine I can't reproduce this bug. I'm using the last version (3.4.0).

Sorry @wagnerluis1982 this was already resolved by #3147

@wagnerluis1982 thanks for your interest in contributing, we really appreciate it. Triaging issues to see if they are still relevant (like you did now) is something that's also very helpful. 馃榿

Was this page helpful?
0 / 5 - 0 ratings