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

Avoid erroring out on unrecognized option until after conftests.py are read #13094

Closed
oleksandr-pavlyk opened this issue Dec 30, 2024 · 3 comments

Comments

@oleksandr-pavlyk
Copy link

What's the problem this feature will solve?

My project, IntelPython/dpctl, includes its test suite in the package layout, so that pytest --pyargs dpctl can be used to run the test suite.

I recently added to conftest.py (which is included in the layout) support for an option, which I tested in the editable build setting, i.e., python -m pytest dpctl/tests --myoption worked as expected.

When the package is installed, however, pytest --pyargd dpctl --myoption fails with ERROR: unrecognized arguments: --myoption.

The only work-around I could find was to copy test folder from the project checkout to a temporary directory dpctl_tests from where I
would run python -m pytest dpctl_tests --myoptions.

My understanding is that when --pyargs is used, arguments must be parsed before test discovery is attempted, and the unknown option causes the error.

Describe the solution you'd like

I would like pytest to defer erroring out on unknown option, only parse --pyargs option to determine where tests are located, and reparse options after conftests.py files are loaded.

@RonnyPfannschmidt
Copy link
Member

Pyargs are evaluated after initial contests loading manage this better

That won't change

Eventually testtpathd eill be expanded to

@oleksandr-pavlyk
Copy link
Author

I think this issue is a duplicate of #1596

@RonnyPfannschmidt
Copy link
Member

Indeed it is

@RonnyPfannschmidt RonnyPfannschmidt closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2024
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

No branches or pull requests

2 participants