gabriel / muse public
conftest.py python
36 lines 1.2 KB
Raw
sha256:88ac91129873e6a496e9189515aa690eb893ae25d69c8f72af141a2be5068eb3 docs: docstring sprint contract→find-symbol — idiomatic run… Sonnet 4.6 patch 140 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 2 commits
sha256:88ac91129873e6a496e9189515aa690eb893ae25d69c8f72af141a2be5068eb3 docs: docstring sprint contract→find-symbol — idiomatic run… Sonnet 4.6 patch 140 days ago
sha256:a09b1b4f6838754495547f200aa0ce88e2f56ffc5b20b900f6f0cff2c3cdede9 fix(cursorignore): remove git-ism (.git/worktrees) Human minor 143 days ago