-
-
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
pytest==8.3.1
collects tests from Python dependencies within conda
environments (regression from 8.2.2
)
#12652
Comments
pytest==8.3.1
collects tests from Python dependencies within venvs (regression from 8.2.2
)pytest==8.3.1
collects tests from Python dependencies within venvs unless norecursedirs
is set (regression from 8.2.2
)
…rom our dependencies within our `venv` (#4571) ## Description With `pytest==8.3.1`, pytest will recursively search our `conda` environment unless we explicitly set `norecursedirs`. ## Related issues/PRs Fixes #4570. For upstream details, see: - pytest-dev/pytest#12652
Does the venv directory contain a |
Yes! # In root of project folder (where tests are located at `./testing`)
master|joshua@monarch:~/repos/spinalcordtoolbox/$ find . -name pyvenv.cfg
./python/envs/venv_sct/pyvenv.cfg |
Interesting. Any chance you can poke the |
In a Python console: >>> from pathlib import Path
>>> def _in_venv(path: Path) -> bool:
"""Attempt to detect if ``path`` is the root of a Virtual Environment by
checking for the existence of the pyvenv.cfg file.
[https://peps.python.org/pep-0405/]"""
try:
return path.joinpath("pyvenv.cfg").is_file()
except OSError:
return False
>>> import os
>>> os.getcwd()
'/home/joshua/repos/spinalcordtoolbox'
>>> _in_venv(Path("./python/envs/venv_sct/"))
True Exploring more on my end too... 🤔 |
Hmm. On my local Linux machine, I get fewer errors. Windows specifically reports many more errors... so I might have to test on a Windows machine. See: |
Just chiming in. We run automated tested in a docker container and on that container, we load the conda prefix inside the project folder. We could probably have done this better, but it was working for us in the past. /projects/projectX: the git repository location Since version 8.3.1 we notice the same issue as described above. Tests from included packages are being discovered. With pytest 8.2.2: collected 190 items / 1 deselected / 189 selected We solved it by adding to pytest.ini
|
it seems like checking only for modern venv left us wanting for conda - is there a similar easy check we could do for conda prefixes/envs -- i'll reach out to conda on fosstodon to get input on fixing this, we might have to undo the steamlining for now |
pytest==8.3.1
collects tests from Python dependencies within venvs unless norecursedirs
is set (regression from 8.2.2
)pytest==8.3.1
collects tests from Python dependencies within conda
environments (regression from 8.2.2
)
For the record, I'm responding to @RonnyPfannschmidt reaching out on Mastodon (https://fosstodon.org/@ossronny/112837662322781627), we'll take a look at this ASAP. |
@RonnyPfannschmidt Can you provide more details other than what was said here, which feature was added in 8.3.1 that triggered this? |
I've filed conda/conda#14069 |
Looks like #12544/#12545 is the culprit that reduces virtualenv detection to look for Given that we can't easily retrofit existing conda environments out there, and a significant number of users are using |
as per #12545 (comment) - i'd slightly prefer adding explicit conda detection over reverting - in case thats not easy/feasible quickly we go with a revert |
@jezdez so the key question - is there a easy foolproof way to check for conda explicitly - even if a |
The best course of action would probably be checking for |
working on a bugfix now, venv detection will be expanded to ("conda-meta", "history") |
initially we accidentially detected conda environmnts by just testing too many files after steamlining we no longer detected conda environments now we explicitly detect conda environments and test for support
initially we accidentially detected conda environmnts by just testing too many files after steamlining we no longer detected conda environments now we explicitly detect conda environments and test for support
released |
pip list
from the virtual environment you are usingwindows-2019
,ubuntu-2022
, etc.)We have the following
setup.cfg
file:When running
pytest
(with no additional options) in the root of our repository, we see the following behavior:pytest==8.2.2
: Only our tests are collected.pytest==8.3.1
: Our tests and the tests of our dependencies are collected, leading to many errors.collecting ... collected 367457 items / 408 errors / 100 skipped
(Woof!)Changing our
setup.cfg
to the following didn't fix the problem either:The fix I used was adding
norecursedirs = {name_of_venv}
Since this involves collection in virtual environments, the reason for the regression might be related to changes in:
Notably, we use a
conda
env withpip
packages installed inside, which may subvert the expectations of the changes in the above PR.The text was updated successfully, but these errors were encountered: