-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Take --pyargs into account to find initial conftests (was: py.test --pyargs my_pkg doesn't run pytest_addoption in my_pkg/conftest.py) #1596
Comments
Thanks for the report! |
By default From pytest_addoption:
I think this logic would have to be extended to also consider |
Right, I thought that included the root of packages. Guess not. :) |
Just FYI, I found this workaround which works - https://stackoverflow.com/a/43747114/2149641 However it basically makes your tests a callable module instead of using |
I showed up here to file exactly this bug but I see someone has beat me to it. I want to be able to execute tests from an installed location, where my "root" |
Any progress on fixing this issue? It has recently cropped up in statsmodels. |
Also bitten by this while running the statsmodels tests... @al1190 |
Hey, hello 2017 larsks! I just into the same problem again and forgot that I had previously filed this bug. @nicoddemus, is this a particularly intractable problem, or just not an interesting one? |
Hey @larsks, Now that the dust has settled a bit with pytest 5.0, I will see if I can get a shot at this. Thanks for the ping. 👍 |
Hi all! I just ran into the same issue, does anyone know a work around? I couldn't find a way to run the tests within an installed package with custom options, apart from:
Oh, and thank you for your work :) EDIT: there was already an answer mentioning a workaround, I should have paid more attention. |
I use a pattern where I define a test function in my projects
This lets me test from an install with
|
@bashtage Oh thanks, I didn't notice a similar workaround had already been shared earlier in the thread. Sorry for the noise 😅 |
How feasible would it be to allow defining options in a That would mean we didn't need to put the |
We stumbled upon this issue in dandi project as well. Please let us know if dust conditions improved. Cheers. |
This is a workaround for pytest-dev/pytest#1596 Without this, testing an installed version of oggm is impossible.
This is a workaround for pytest-dev/pytest#1596 Without this, testing an installed version of oggm is impossible.
This is a workaround for pytest-dev/pytest#1596 Without this, testing an installed version of oggm is impossible.
This is rather broken, see pytest-dev/pytest#1596
This is a workaround for pytest-dev/pytest#1596 Without this, testing an installed version of oggm is impossible.
As part of our build process, we run the test suite after creating the packaging to check that the installed package works as intended. We recently added an option to py.test for some conditional testing, by placing a function
pytest_addoption
in theconftest.py
file that is in the root of the package (so next tomy_pkg/__init__.py
). When calling py.test on the source, this works as intended. Tests are skipped when we omit the option, and they are executed when we pass the option.my_pkg/conftest.py
:However, when we run
py.test --pyargs my_pkg
in an environment where the built package is installed, we see the following error message (even though the test suite is run):All other tests, including those depending on fixtures in the same
conftest.py
file, simply pass.We're running on Windows and Linux, and both on dev machines as on CI (AppVeyor and Codeship), this scenario occurs. We're using the following related packages:
Running with
--traceconfig
does show that theconftest.py
file is registered:PLUGIN registered: <module 'my_pkg.conftest' from 'C:\\Users\\Korijn\\Miniconda3\\envs\\_test\\lib\\site-packages\\my_pkg\\conftest.py'>
full output:
I tried adding a default value:
This avoids the exception, but I still can't pass the option:
The text was updated successfully, but these errors were encountered: