Skip to content

test_import leaves files in the current directory #155731

Description

@serhiy-storchaka

Bug report

Three tests in test_import leave files in the current directory:

$ ./python -m test --fail-env-changed test_import -m test.test_import.ImportTests.test_import
Warning -- files was modified by test_import
Warning --   Before: []
Warning --   After:  ['__pycache__/']
Result: ENV CHANGED
  • ImportTests.test_import and ImportTracebackTests.test_unencodable_filename import a temporary script and do not remove the __pycache__ directory created for it.
  • ImportTests.test_import_in_del_does_not_crash creates a script with make_script() and never unlinks it, leaving @test_<pid>_tmpæ.py.

Running the whole file passes: the leftovers are removed by other tests before the environment is checked.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    3.16new features, bugs and security fixes
    on Aug 13, 2026
  2. nightcityblade commented on Aug 13, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  3. added a commit that references this issue on Aug 13, 2026
  4. added 2 commits that reference this issue on Aug 13, 2026
  5. added a commit that references this issue on Aug 14, 2026
  6. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixes3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions