Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
GIT_ENV = {"GIT_CONFIG_GLOBAL": "/dev/null", "GIT_CONFIG_NOSYSTEM": "1"}


@pytest.fixture(autouse=True)
def no_real_app_helper(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
def isolate_github_auth(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
for name in ("GH_TOKEN", "GITHUB_TOKEN"):
monkeypatch.delenv(name, raising=False)
monkeypatch.setattr(github, "APP_TOKEN_HELPER", tmp_path / "absent-app-token", raising=False)
monkeypatch.setattr(github, "_app_token_cache", ("", 0.0), raising=False)


@pytest.fixture(autouse=True)
def no_host_github_credentials(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
isolate_github_auth(tmp_path, monkeypatch)


for _role in ("AUTHOR", "COMMITTER"):
GIT_ENV |= {f"GIT_{_role}_NAME": "test", f"GIT_{_role}_EMAIL": "test@example.com"}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_gh_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from loopzero import github
from loopzero.types import Finding, ReviewResult
from tests.conftest import isolate_github_auth
from tests.test_github import (
HEAD,
PR_FILES,
Expand Down Expand Up @@ -50,8 +51,7 @@ def captured_argv(tmp_path_factory: pytest.TempPathFactory) -> list[dict]:

with pytest.MonkeyPatch.context() as env:
env.setenv("PATH", str(tmp_path), prepend=os.pathsep)
env.setattr(github, "APP_TOKEN_HELPER", tmp_path / "absent-app-token")
env.setattr(github, "_app_token_cache", ("", 0.0))
isolate_github_auth(tmp_path, env)
github.pr_for_branch(REPO, "lz/x")
github.pr_view(REPO, 7)
github.create_draft_pr(REPO, "lz/x", "main", "Title", "Body\n")
Expand Down
Loading