Skip to content

Pytest seems to search and create files in site-packages directory when not prompted to #10781

@hmaarrfk

Description

@hmaarrfk

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:

  1. Install an optional package
  2. Run pytest
  3. 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 conda-forge/cupy-feedstock#188 (comment)

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanismtype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions