pytest-dev / pytest-dev/pytest
Pytest seems to search and create files in site-packages directory when not prompted to
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
It seems that if pytest is run in a development directory, it can create files in site-packages/.../__pycache__ which can cause modules to continue getting "imported" even when they are uninstalled.
Many packages use import X as proof of an X package is installed and available.
If you:
- Install an optional package
- Run pytest
- Uninstall the optional package
It can leave your environment in a broken state.
Your input on "why" this is happening would be appreciated.
I wrote out my explanation and reproducer https://github.com/conda-forge/cupy-feedstock/issues/188#issuecomment-1449217000
- a detailed description of the bug or problem you are having
- output of
pip listfrom the virtual environment you are using - pytest and operating system versions
- minimal example if possible
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the optional-package install, pytest run, uninstall, and subsequent import behavior described in the issue and linked reproducer. Inspect the resulting site-packages/.../pycache files and compare the environment before and after using the listed pytest, operating system, and pip details. Done means the cause is established and a concrete fix or mitigation is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100