← Back to issue list

tests: protect fixture against chdir mocks

View original Github issue

Metadata

Project
craft-parts
Number
#439
Type
pull request
State
merged
Author
cmatsuoka
Labels
Created
Updated
Closed

Current evaluation

Merged updates to the new_dir test fixture to always call the original os.chdir. This prevents unexpected behavior when tests mock the function. Approved by one reviewer and modified three files.

Suggested action:

No scores available.

Issue body

Always call the original os.chdir in the new_dir fixture to prevent unexpected behavior if os.chdir is mocked in a test. Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com> - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? -----

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged updates to the new_dir test fixture to always call the original os.chdir. This prevents unexpected behavior when tests mock the function. Approved by one reviewer and modified three files.
qwen3.6-35b-a3b-mtp-q6 Merged updates to the new_dir fixture that explicitly invoke the original os.chdir function, preventing unexpected behavior when os.chdir is mocked during tests.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#624 test: use `new_dir` fixture craft-parts merged Merged after two approvals and passing CI. Replaced hardcoded temp file creation in two unit tests with the new_dir fixture to improve isolation. A side discussion suggested adding pyfakefs to test dependencies.
74%
#118 tests: use tmp_path instead of mock_path rockcraft merged Merged a unit test fix replacing mock_path with tmp_path to resolve fixture scope issues. Approved by one reviewer, passed CI, and modified 1 file (+3/-3 lines).
72%
#575 test: fix mock chroot fixture craft-parts merged Merged a one-line fix for the mock chroot test fixture to ensure Python 3.11 compatibility, aligning with upstream CPython changes. Approved by two reviewers and passed CI checks.
71%