Skip to content

Conversation

@esafak
Copy link
Contributor

@esafak esafak commented Aug 4, 2025

The test test_py_info_cache_invalidation_on_py_info_change modifies the py_info.py script to test cache invalidation. However, it did not restore the original modification time of the file, which caused .pyc files to be invalidated, leading to QA notices in some packaging environments.

This change remedies the situation by saving the file's stat info before modification and restoring the atime and mtime in the test's finally block. This ensures that the file's timestamp is not permanently altered by the test run.

Fixes #2933

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

The test `test_py_info_cache_invalidation_on_py_info_change` modifies the `py_info.py` script to test cache invalidation. However, it did
not restore the original modification time of the file, which caused
`.pyc` files to be invalidated, leading to QA notices in some
packaging environments.

This change remedies the situation by saving the file's stat info before modification and restoring the atime and mtime in the test's finally block. This ensures that the file's timestamp is not permanently altered by the test run.

Fixes pypa#2933

Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
@gaborbernat gaborbernat enabled auto-merge August 4, 2025 19:58
@gaborbernat gaborbernat merged commit 4cd7b13 into pypa:main Aug 4, 2025
42 checks passed
@esafak esafak deleted the fix/2933-pyc-invalidation-test branch August 4, 2025 20:22
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

Successfully merging this pull request may close these issues.

test_py_info_cache_invalidation_on_py_info_change alters py_info.py, invalidating .pyc files

2 participants