Skip to content

Incorrect pyc cache loaded when test file is updated in short time #13292

Closed

Description

@jnhyperion

given this test:

def test_example(pytester):
    pytester.makepyfile("""
    def test_dummy1():
        def func():
            pass
        print(func.__qualname__)
    """)
    r = pytester.runpytest("-s")
    assert r.ret.value == 0
    assert "test_example.py test_dummy1.<locals>.func" in r.stdout.str()
    pytester.makepyfile("""
    def test_dummy2():
        def func():
            pass
        print(func.__qualname__)
    """)
    r = pytester.runpytest("-s")
    assert r.ret.value == 0
    assert "test_example.py test_dummy2.<locals>.func" in r.stdout.str()

the test file is modified and reload in short time, when the 2nd test execution start, it will still load the test file before modified from __pycache__, so the test will randomly failed.

Activity

  1. Zac-HD commented on Nov 3, 2025

    @Zac-HD
    Member

    Closing per #13293 (comment), with some hope of #11418 improving things.

  2. added a commit that references this issue on Aug 19, 2026
    cd1a87a
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions