Skip to content

fix: keep relative isolation roots stable across chdir - #643

Open
0x5t4l1n wants to merge 1 commit into
tox-dev:mainfrom
0x5t4l1n:fix/pin-relative-isolation-root
Open

0x5t4l1n wants to merge 1 commit into
tox-dev:mainfrom
0x5t4l1n:fix/pin-relative-isolation-root

Conversation

@0x5t4l1n

Copy link
Copy Markdown

isolated_dirs("sandbox") retains a relative root. If the test changes its working directory inside the context, every redirected path follows the new working directory, and ensure_exists=True creates directories outside the original isolation root. Passing "." has the same problem.

Make the root absolute once when entering the context. Directory lookups, directory creation and the yielded root then keep referring to the original location across working-directory changes. Absolute roots keep their existing behavior.

Add two regression cases covering "." and a named relative root. Each checks all directory accessors and iterators, the yielded root, and actual directory creation after changing directories. Both fail on the original implementation and pass with the fix. Update the helper documentation, how-to guide and changelog.

Validation:

  • Windows Tox, CPython 3.11.17 and 3.14.9: each 2,043 passed, 350 skipped; 100% changed-line coverage, including the new tests.
  • Linux (WSL), CPython 3.13.12: full suite, 2,268 passed, 125 skipped.
  • Repository-wide strict type checking and Ruff lint/format checks passed.
  • Sphinx HTML build with warnings treated as errors, Proselint and Towncrier draft rendering passed.
  • All 14 configured pre-commit hooks passed through Tox after accepting the documentation formatter's wrapping and restoring unrelated YAML files to their checked-in LF line endings.
  • Source/wheel builds, Twine metadata checks and wheel-content checks passed through Tox.
  • Tox strict type checking and combined coverage passed; combined changed-line coverage is 100%.

Tox tooling uses local overrides selecting Python 3.14 instead of the unavailable configured Python 3.15. The initial aggregate run flagged formatter changes; its fix environment passed on rerun. Python 3.12, Windows 3.13, 3.15, PyPy and free-threaded interpreters were unavailable; native macOS was not tested. No repository test, workflow or tooling configuration is changed.

Prepared and tested with Codex assistance.

@Muguett-DBY Muguett-DBY 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.

Tested 411d04d on CPython 3.12: Linux and macOS each had 2,268 passed / 125 skipped; Windows had 2,043 passed / 350 skipped.

Both added regressions fail with the original testing.py restored. I also checked deferred context entry, nested relative roots with exception restoration, parent-relative Path inputs, directory symlinks, and Windows drive-relative roots. These pass with the fix, including directory creation after changing cwd. The absolute-root check confirms that existing .. components are retained, and the symlink check confirms that the alias spelling is preserved.

Test source and logs. No issues found in this scope. Reviewed with Codex assistance.

This branch has not been deployed

No deployments
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.

2 participants