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

IncrementalPlugin does not use norecursedirs and --ignore options? #9

Open
jneeven opened this issue May 28, 2021 · 6 comments
Open
Labels

Comments

@jneeven
Copy link

jneeven commented May 28, 2021

Hi! This looks like an awesome package so I've been trying to get it running, but whenever I run pytest it now gets stuck forever. I've printed the trace and added some print statements, and it appears that the IncrementalPlugin ignores the norecursedirs option of my pytest config, which results in it trying to parse my entire virtual environment stored in the same folder...

The problem seems to be with this part of the code:
https://github.com/pytest-dev/pytest-incremental/blob/master/pytest_incremental.py#L577

Since I have no explicit watch path set (I want to process all files except those I explicitly ignore, such as my virtual environment), it just defaults to os.getcwd(). Is this a deliberate choice? I'm not sure how exactly pytest uses the norecursedirs option internally, but it does work correctly in the sense that if I disable pytest-incremental, it does indeed skip those folders. The same is true for the --ignore command line option.

I assume having a virtual environment in the same folder is a pretty common thing to do, so perhaps I'm missing something or doing something wrong? Thanks!

@schettino72
Copy link
Member

Yes, the plugin should take these options into account.

I guess no harm in ignoring vitualenvs by default as well. Any reliable way to detect those.

it just defaults to os.getcwd(). Is this a deliberate choice?

I can't image anything else to be used as default.

I assume having a virtual environment in the same folder is a pretty common thing to do, so perhaps I'm missing something or doing something wrong?

Not wrong. Although I use virtualenvwrapper & Virtual Fish, where all virtualenvs are kept on same location.

@jneeven
Copy link
Author

jneeven commented May 28, 2021

I guess no harm in ignoring vitualenvs by default as well. Any reliable way to detect those.

Good question, mine has a file pyvenv.cfg in it but that's probably not universal. I think any folder with a ./bin/python in there is probably a safe bet, but it may not catch everything.

Yes, the plugin should take these options into account.

On a related note; is there any way to specify the --inc-path arguments in a setup.cfg as well? I've tried adding watch-patch and inc-path, but neither works :(

@schettino72
Copy link
Member

On a related note; is there any way to specify the --inc-path arguments in a setup.cfg as well? I

I use pytest.ini. Is this setup.cfg supported by pytest? Never tried it but it should work if supported by pytest.

@jneeven
Copy link
Author

jneeven commented May 28, 2021

Is this setup.cfg supported by pytest?

It is, but looking at the docs it appears to be discouraged. I'll try using pytest.ini instead 👍

@jneeven
Copy link
Author

jneeven commented May 28, 2021

I've tried using the following pytest.ini:

[pytest]
addopts = --inc
norecursedirs = 
    ignored
    venv
    .venv
    env
    .env
    .pytype
    **/snapshots
    __pycache__
    build
    dist

Which correctly ignores these folders if I remove the addopts = --inc, but starts searching them for dependencies if --inc is enabled. So unfortunately this isn't just an artifact of using setup.cfg :(

@pjmcdermott
Copy link

pjmcdermott commented Jul 1, 2024

Just ran into this issue 3 years later when I switched from virtualenvwrapper (which puts virtual environments in ~/.virtualenvs) to direnv using layout_python3 which places the virtual environment in the .direnv folder of the project directory.

Running without --inc appears to work fine. Adding ".direnv" to norecursedirs in my pyproject.toml did not resolve.

My experience is that pytest --inc does eventually work, it just takes so long that it appears to have hung...It also hoovers up memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants