conftest.py
python
sha256:b636f72dcba9e190afb980bece906fa5b717fbde014b76ef023df8cb96e01eb9
docs: expand cache plan with all seven testing tiers and do…
Sonnet 4.6
131 days ago
| 1 | """Pytest configuration and shared fixtures for the muse test suite. |
| 2 | |
| 3 | All fixtures defined here are automatically available to every test module |
| 4 | in the ``tests/`` directory without explicit import. |
| 5 | """ |
| 6 | |
| 7 | from __future__ import annotations |
| 8 | |
| 9 | import os |
| 10 | from typing import Generator |
| 11 | |
| 12 | import pytest |
| 13 | |
| 14 | |
| 15 | @pytest.fixture(autouse=True) |
| 16 | def _restore_cwd() -> Generator[None, None, None]: |
| 17 | """Restore the working directory and MUSE_REPO_ROOT after every test. |
| 18 | |
| 19 | Several tests call ``os.chdir()`` to enter a temporary repository, and |
| 20 | some directly mutate ``os.environ["MUSE_REPO_ROOT"]`` without cleanup. |
| 21 | Without this fixture those side-effects leak into subsequent tests, |
| 22 | causing ``find_repo_root()`` to resolve against a stale path and |
| 23 | producing spurious failures across the entire suite. |
| 24 | |
| 25 | Note: module-scoped fixtures that set these values run *before* this |
| 26 | function-scoped fixture captures them, so they must manage their own |
| 27 | cleanup (yield + restore in the fixture body). |
| 28 | """ |
| 29 | original_cwd = os.getcwd() |
| 30 | original_root = os.environ.get("MUSE_REPO_ROOT") |
| 31 | yield |
| 32 | os.chdir(original_cwd) |
| 33 | if original_root is None: |
| 34 | os.environ.pop("MUSE_REPO_ROOT", None) |
| 35 | else: |
| 36 | os.environ["MUSE_REPO_ROOT"] = original_root |
File History
3 commits
sha256:b636f72dcba9e190afb980bece906fa5b717fbde014b76ef023df8cb96e01eb9
docs: expand cache plan with all seven testing tiers and do…
Sonnet 4.6
131 days ago
sha256:7f9e2ef5286aedad9c1e6011b4c46ca27f39dbdad6e3409357e36b26e46b3b7c
docs: docstring sprint for-each-ref→hotspots — idiomatic ru…
Sonnet 4.6
patch
137 days ago
sha256:a09b1b4f6838754495547f200aa0ce88e2f56ffc5b20b900f6f0cff2c3cdede9
fix(cursorignore): remove git-ism (.git/worktrees)
Human
minor
⚠
140 days ago