Skip to content

test: isolate root directory checks from inherited XDG settings - #622

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
shoaibulhaque:test/isolate-root-xdg-environment
Oct 17, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
shoaibulhaque:test/isolate-root-xdg-environment

Conversation

@shoaibulhaque

Copy link
Copy Markdown
Contributor

Problem

The root-redirection tests expect default site directories such as /usr/local/share and /etc/xdg. The _as_root fixture changes getuid(), but leaves the host's XDG variables in place. On a desktop session with XDG_DATA_DIRS and XDG_CONFIG_DIRS set, twelve tests fail because the library correctly uses those configured paths.

Fix

Make _as_root depend on the existing _clear_xdg_env fixture. The root tests then start from the environment their assertions expect. Tests that exercise XDG overrides still set their own values after fixture setup.

Validation

  • Before the change, the full suite reports twelve failures with this host's XDG directory lists.
  • After the change, the full suite passes without unsetting host variables in the test command: 2233 passed, 125 skipped on Python 3.12.
  • Ruff lint, Ruff format, type and whitespace checks pass.

This changes test setup only.

Root-redirection tests expect the default site directories, but the
_as_root fixture only changes getuid(). XDG_DATA_DIRS and
XDG_CONFIG_DIRS inherited from a desktop session change those paths
and cause twelve tests to fail.

Make the fixture depend on the existing _clear_xdg_env fixture.
Each test can still set its own XDG values after fixture setup.

Validation: the full suite passes with the host environment intact:
2233 passed, 125 skipped. Ruff, type and whitespace checks pass.
@gaborbernat
gaborbernat enabled auto-merge (squash) October 17, 2026 18:01
@gaborbernat gaborbernat added the skip news No news fragment needed label Oct 17, 2026
@gaborbernat gaborbernat removed the skip news No news fragment needed label Oct 17, 2026
@gaborbernat
gaborbernat merged commit da89726 into tox-dev:main Oct 17, 2026
33 checks passed
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