8Provide shared fixtures for ``oct.core`` tests, in particular the git
9integration tests in ``test_git.py`` (Phase 4A / G-A6).
13- ``git_repo``: initialise a real git repository in a pytest tmp_path
14 and return its resolved path. Skips the test if the ``git`` binary is
15 not available on the host.
16- ``can_symlink``: cached session-scoped probe that determines whether
17 the platform allows creating symlinks in a temp directory (Linux/
18 macOS always, Windows only with Developer Mode or admin).
24 L2 — fixture lifecycle
25 L3 — fixture setup details
30- ``git_repo`` always returns a directory that is a real git working
31 tree with ``user.name`` / ``user.email`` pre-configured so that
32 commit operations in tests do not fail on unconfigured identity.
33- ``can_symlink`` must never raise; it returns ``True`` or ``False``.
39from pathlib
import Path
44@pytest.fixture(scope="session")
46 """Session-cached probe: True if symlink creation works on this host."""
47 probe_dir = tmp_path_factory.mktemp(
"symlink_probe")
48 target = probe_dir /
"target.txt"
49 link = probe_dir /
"link.txt"
50 target.write_text(
"x", encoding=
"utf-8")
52 os.symlink(target, link)
53 except (OSError, NotImplementedError):
59 return shutil.which(
"git")
is not None
64 """Initialise a real git repo in tmp_path; skip if git is missing."""
66 pytest.skip(
"git binary not available on PATH")
67 repo = tmp_path /
"repo"
70 [
"git",
"init",
"--quiet",
"-b",
"main"],
71 cwd=repo, check=
True, capture_output=
True, text=
True,
74 [
"git",
"config",
"user.email",
"test@example.com"],
75 cwd=repo, check=
True, capture_output=
True, text=
True,
78 [
"git",
"config",
"user.name",
"Test"],
79 cwd=repo, check=
True, capture_output=
True, text=
True,
82 [
"git",
"config",
"commit.gpgsign",
"false"],
83 cwd=repo, check=
True, capture_output=
True, text=
True,
88def commit_file(repo: Path, name: str, content: str, message: str) ->
None:
89 """Helper: write a file, stage it, commit it. Used by several tests."""
90 (repo / name).write_text(content, encoding=
"utf-8")
93 cwd=repo, check=
True, capture_output=
True, text=
True,
96 [
"git",
"commit",
"-m", message,
"--quiet"],
97 cwd=repo, check=
True, capture_output=
True, text=
True,
bool can_symlink(tmp_path_factory)
None commit_file(Path repo, str name, str content, str message)
Path git_repo(Path tmp_path)