Skip to content

Only use files_manager in the test suite#1827

Merged
nathanjmcdougall merged 2 commits into
mainfrom
copilot/enforce-files-manager-in-tests
Apr 6, 2026
Merged

Only use files_manager in the test suite#1827
nathanjmcdougall merged 2 commits into
mainfrom
copilot/enforce-files-manager-in-tests

Conversation

Copilot AI commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Tests inconsistently used individual file manager context managers (PyprojectTOMLManager, SetupCFGManager, etc.) instead of the unified files_manager(). This made tests fragile and inconsistent—files_manager() locks all managers atomically, which is the correct pattern.

Test file changes (~270 replacements across 28 files)

  • Simple cases: with change_cwd(tmp_path), PyprojectTOMLManager():with change_cwd(tmp_path), files_manager():
  • Multi-manager cases: collapsed PyprojectTOMLManager(), UVTOMLManager() into single files_manager()
  • as binding cases: moved manager instantiation into the body since files_manager() already locks the class-level state:
# Before
with change_cwd(tmp_path), PyprojectTOMLManager() as mgr:
    mgr[["tool", "uv", "environments"]] = []

# After
with change_cwd(tmp_path), files_manager():
    mgr = PyprojectTOMLManager()
    mgr[["tool", "uv", "environments"]] = []
  • Updated imports: added files_manager, removed now-unused manager imports

Enforcement hook

Added a pygrep-language prek hook no-bare-managers-in-tests matching ^\s*with\b.*Manager\( in tests/, excluding the three base manager infrastructure test files (test_ini_io_.py, test_toml_io_.py, test_yaml_io_.py) that legitimately use custom My*Manager() subclasses.

Copilot AI changed the title [WIP] Refactor test suite to only use files_manager Only use files_manager in the test suite Apr 6, 2026
Copilot AI requested a review from nathanjmcdougall April 6, 2026 19:41
@codecov

codecov Bot commented Apr 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Apr 6, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/enforce-files-manager-in-tests (3bb8eba) with main (7c45f33)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 6, 2026 19:59
@nathanjmcdougall nathanjmcdougall merged commit 73c07b7 into main Apr 6, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/enforce-files-manager-in-tests branch April 6, 2026 19:59
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.

Only use files_manager in the test suite

2 participants