diff options
| author | Mohamed Hegazy <mhegazy@anthropic.com> | 2026-10-20 23:09:45 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-10-20 23:09:45 +0000 |
| commit | f3d27ec9912bf26abfdb1b2bb0aba020d36a5491 (patch) | |
| tree | 9ba750250de76ccff3ca3d11da67ddf5f880a907 /plugins | |
| parent | f5ce0a810148d3d86cd7ac99b007289fd8e3fb15 (diff) | |
security-guidance: write the baseline lookup test files as bytes
The fixture wrote its files with write_text, which stores "\n" as "\r\n" on
Windows, so the committed text no longer equalled the string the tests compare
against. The files are now written as bytes.
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/security-guidance/tests/test_baseline_lookup.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/security-guidance/tests/test_baseline_lookup.py b/plugins/security-guidance/tests/test_baseline_lookup.py index b43c30b9..ef8ab360 100644 --- a/plugins/security-guidance/tests/test_baseline_lookup.py +++ b/plugins/security-guidance/tests/test_baseline_lookup.py @@ -21,7 +21,15 @@ def write_payload(cwd, file_path, content, session_id="s1"): @pytest.fixture def repo(tmp_path): - return make_repo(tmp_path / "ws" / "mono", {FILE: OLD, "top.py": OLD}) + repo = make_repo(tmp_path / "ws" / "mono") + # Bytes, so the committed text is OLD on every platform: write_text turns + # "\n" into "\r\n" on Windows. + for name in (FILE, "top.py"): + (repo / name).parent.mkdir(parents=True, exist_ok=True) + (repo / name).write_bytes(OLD.encode()) + git(repo, "add", "-A") + git(repo, "commit", "-q", "-m", "add files") + return repo @pytest.fixture @@ -62,7 +70,7 @@ class TestBaselineFileContent: # still not this session's baseline. git(repo, "worktree", "add", "-q", str(tmp_path / "ws" / "other"), "-b", "other") twin = tmp_path / "ws" / "other" / FILE - assert twin.read_text() == OLD + assert twin.read_bytes().replace(b"\r\n", b"\n") == OLD.encode() for cwd in (repo, repo / "packages" / "app"): assert diffstate.get_baseline_file_content("s1", str(twin), str(cwd)) is None |
