Skip to content

test: consolidate helper test cases - #11006

Open
Himanshuagrawal4 wants to merge 1 commit into
python-poetry:mainfrom
Himanshuagrawal4:PRO/poetry-test-cleanup-20260808
Open

test: consolidate helper test cases#11006
Himanshuagrawal4 wants to merge 1 commit into
python-poetry:mainfrom
Himanshuagrawal4:PRO/poetry-test-cleanup-20260808

Conversation

@Himanshuagrawal4

Copy link
Copy Markdown

Relates-to: #3155

Summary

  • parameterize normal and exceptional exits for the working-directory helper
  • parameterize existing-file and existing-directory behavior for ensure_path
  • retain the same coverage with less duplicated setup and assertion code

Validation

  • ruff check tests/utils/test_helpers.py
  • ruff format --check tests/utils/test_helpers.py
  • pytest tests/utils/test_helpers.py (48 passed)

Checklist

  • Test coverage remains focused on the changed test cases.
  • Documentation is not affected by this test-only cleanup.

@Himanshuagrawal4
Himanshuagrawal4 marked this pull request as ready for review August 8, 2026 19:19

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The combined test_directory_restores_working_directory currently uses with (pytest.raises(...) if raises else contextlib.nullcontext(), directory(tmp_path),):, which creates a tuple context manager and will not work as intended; consider rewriting to use multiple context managers correctly (e.g., ctx = pytest.raises(...) if raises else contextlib.nullcontext(); with ctx, directory(tmp_path): ...).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The combined `test_directory_restores_working_directory` currently uses `with (pytest.raises(...) if raises else contextlib.nullcontext(), directory(tmp_path),):`, which creates a tuple context manager and will not work as intended; consider rewriting to use multiple context managers correctly (e.g., `ctx = pytest.raises(...) if raises else contextlib.nullcontext(); with ctx, directory(tmp_path): ...`).

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant