Skip to content

fix: bytecode cache invalidation for moved test files (#14552) - #14989

Open
15r10nk wants to merge 1 commit into
pytest-dev:mainfrom
15r10nk:fix-stale-cached-bytecode-on-file-move
Open

fix: bytecode cache invalidation for moved test files (#14552)#14989
15r10nk wants to merge 1 commit into
pytest-dev:mainfrom
15r10nk:fix-stale-cached-bytecode-on-file-move

Conversation

@15r10nk

@15r10nk 15r10nk commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

solves #14552

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 8, 2026
@15r10nk
15r10nk marked this pull request as ready for review September 8, 2026 13:05

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for starting this

Unfortunately the test doesn't validate the invariant holding

pytester.path.joinpath("test1").rename(pytester.path.joinpath("test2"))

second = pytester.runpytest_subprocess("-s", "test2/test_a.py")
second.assert_outcomes(passed=1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't validate the invatiant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what is missing here for you.

  • The tests fails without the fix.
  • It reproduces the incorrect behaviour by moving the source and cached bytecode.

Which invariant do you mean?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test would pass without changes when one disables bytecode writing for example

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill show a more detailed example once I get back to the computer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants