Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jnhyperion opened this issue Mar 13, 2025 · 0 comments
Open

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

jnhyperion opened this issue Mar 13, 2025 · 0 comments

Comments

@jnhyperion
Copy link

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.

jnhyperion added a commit to jnhyperion/pytest that referenced this issue Mar 13, 2025
jnhyperion added a commit to jnhyperion/pytest that referenced this issue Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant