GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_modulefinder always modifies execution environment · Issue #93616 · python/cpython

test_modulefinder always modifies execution environment #93616

New issue
Copy link
New issue
Copy link
Closed
#93617
Closed
test_modulefinder always modifies execution environment#93616
#93617
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@tiran
tiran
opened on Jun 8, 2022
Issue body actions

Bug report

test_modulefinder creates a temporary directory in its global module scope

cpython/Lib/test/test_modulefinder.py

Lines 13 to 14 in 22df2e0

TEST_DIR = tempfile.mkdtemp()
TEST_PATH = [TEST_DIR, os.path.dirname(tempfile.__file__)]

and removes the temporary directory in each test method

cpython/Lib/test/test_modulefinder.py

Lines 349 to 350 in 22df2e0

finally:
shutil.rmtree(TEST_DIR)

If the test is executed in an environment without test worker processes (e.g. WASI) then the test runner complains about changes to the execution environment:

/python-wasm/cpython/builddir/wasi# wasmtime run --mapdir .::../../ -- python.wasm -m test --fail-env-changed test_modulefinder
0:00:00 Run tests sequentially
0:00:00 [1/1] test_modulefinder
Warning -- files was modified by test_modulefinder
Warning --   Before: ['tmp8avdrxn0/']
Warning --   After:  [] 
test_modulefinder failed (env changed)

== Tests result: ENV CHANGED ==

1 test altered the execution environment:
    test_modulefinder

Total duration: 292 ms
Tests result: ENV CHANGED

test_modulefinder should create the temporary directory in setUp and rmtree it in tearDown methods instead.

Activity

  1. tiran
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jun 8, 2022
  2. tiran
    added a commit that references this issue on Jun 8, 2022

    pythongh-93616: Fix env changed issue in test_modulefinder

    fcb770d
  3. tiran
    linked a pull request that will close this issuegh-93616: Fix env changed issue in test_modulefinder #93617on Jun 8, 2022
  4. tiran
    added
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    on Jun 8, 2022
  5. tiran
    closed this as completedin #93617on Jun 9, 2022
  6. miss-islington
    added a commit that references this issue on Jun 9, 2022

    pythongh-93616: Fix env changed issue in test_modulefinder (pythonGH-…

    0d1b687
  7. tiran
    added a commit that references this issue on Jun 9, 2022

    gh-93616: Fix env changed issue in test_modulefinder (GH-93617)

    cffa4f7
  8. miss-islington
    added a commit that references this issue on Jun 9, 2022

    gh-93616: Fix env changed issue in test_modulefinder (GH-93617)

    98bbbbe
  9. serhiy-storchaka
    added a commit that references this issue on Jun 26, 2022

    Revert 30935 defer bpo45162 to 312 (#94285)

    1ffde3e
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.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.