Skip to content

gh-37883: Safely skip test_resource file size tests when limits are strict#145579

Open
Shrey-N wants to merge 3 commits intopython:mainfrom
Shrey-N:fixy-branch
Open

gh-37883: Safely skip test_resource file size tests when limits are strict#145579
Shrey-N wants to merge 3 commits intopython:mainfrom
Shrey-N:fixy-branch

Conversation

@Shrey-N
Copy link
Contributor

@Shrey-N Shrey-N commented Mar 6, 2026

This fixes the Standing issue #37883 where test_resource would fail on systems with file size limitations

Previous attempts (like #140872) tried to introduce massive refactoring and helper classes. Based on reviewer feedback I read there, I have tried a minimal fix

  • It checks if the system's hard limit is large enough, and if the OS actually allows the limit to be modified. If not, it uses self.skipTest with an informative message rather than failing with an unhandled OSError or ValueError.
  • It replaces the fragile dual try...finally resource restoration blocks with self.addCleanup(), guaranteeing that limits are reset even during a test assertion failure.

Fixes #37883

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Mar 6, 2026
@python-cla-bot
Copy link

python-cla-bot bot commented Mar 6, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@Shrey-N
Copy link
Contributor Author

Shrey-N commented Mar 6, 2026

I have added a news entry, though I am not sure if it's necessary or for this fix, Please let me know if I should remove it :)

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

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_resource fails when file size is limited

1 participant