|
8 | 8 |
|
9 | 9 | import pytest |
10 | 10 |
|
11 | | -_MODULE_PATH = Path(__file__).resolve().parent.parent / "wiki" / "tools" / "check_sync.py" |
| 11 | +_MODULE_PATH = ( |
| 12 | + Path(__file__).resolve().parent.parent / "wiki" / "tools" / "check_sync.py" |
| 13 | +) |
12 | 14 | _spec = importlib.util.spec_from_file_location("check_sync", _MODULE_PATH) |
13 | 15 | check_sync = importlib.util.module_from_spec(_spec) |
14 | 16 | sys.modules["check_sync"] = check_sync |
@@ -55,7 +57,11 @@ class TestGlobToRegex: |
55 | 57 | [ |
56 | 58 | ("src/ncca/ngl/vec*.py", "src/ncca/ngl/vec3.py", True), |
57 | 59 | ("src/ncca/ngl/vec*.py", "src/ncca/ngl/vec3_array.py", True), |
58 | | - ("src/ncca/ngl/vec*.py", "src/ncca/ngl/opengl/vec3.py", False), # * stays in one dir |
| 60 | + ( |
| 61 | + "src/ncca/ngl/vec*.py", |
| 62 | + "src/ncca/ngl/opengl/vec3.py", |
| 63 | + False, |
| 64 | + ), # * stays in one dir |
59 | 65 | ("src/ncca/ngl/webgpu/**", "src/ncca/ngl/webgpu/line_pipeline.py", True), |
60 | 66 | ("**/conftest.py", "tests/conftest.py", True), |
61 | 67 | ("**/conftest.py", "conftest.py", True), # **/ also matches zero dirs |
@@ -99,27 +105,35 @@ def wiki_repo(tmp_path): |
99 | 105 |
|
100 | 106 | class TestCheckPage: |
101 | 107 | def test_fresh_when_sources_unchanged(self, wiki_repo): |
102 | | - status = check_sync.check_page(wiki_repo, wiki_repo / "wiki" / "modules" / "math.md") |
| 108 | + status = check_sync.check_page( |
| 109 | + wiki_repo, wiki_repo / "wiki" / "modules" / "math.md" |
| 110 | + ) |
103 | 111 | assert status.state == "fresh" |
104 | 112 | assert status.changed == [] |
105 | 113 |
|
106 | 114 | def test_stale_when_source_changes_after_sync(self, wiki_repo): |
107 | 115 | (wiki_repo / "src" / "ncca" / "ngl" / "vec3.py").write_text("x = 2\n") |
108 | 116 | _git(wiki_repo, "commit", "-am", "change vec3") |
109 | | - status = check_sync.check_page(wiki_repo, wiki_repo / "wiki" / "modules" / "math.md") |
| 117 | + status = check_sync.check_page( |
| 118 | + wiki_repo, wiki_repo / "wiki" / "modules" / "math.md" |
| 119 | + ) |
110 | 120 | assert status.state == "stale" |
111 | 121 | assert status.changed == ["src/ncca/ngl/vec3.py"] |
112 | 122 |
|
113 | 123 | def test_fresh_when_unrelated_file_changes(self, wiki_repo): |
114 | 124 | (wiki_repo / "README.md").write_text("hello\n") |
115 | 125 | _git(wiki_repo, "add", ".") |
116 | 126 | _git(wiki_repo, "commit", "-m", "add readme") |
117 | | - status = check_sync.check_page(wiki_repo, wiki_repo / "wiki" / "modules" / "math.md") |
| 127 | + status = check_sync.check_page( |
| 128 | + wiki_repo, wiki_repo / "wiki" / "modules" / "math.md" |
| 129 | + ) |
118 | 130 | assert status.state == "fresh" |
119 | 131 |
|
120 | 132 | def test_error_on_unknown_synced_commit(self, wiki_repo): |
121 | 133 | page = wiki_repo / "wiki" / "modules" / "math.md" |
122 | | - page.write_text("---\nsources:\n - src/ncca/ngl/vec*.py\nsynced: " + "0" * 40 + "\n---\n") |
| 134 | + page.write_text( |
| 135 | + "---\nsources:\n - src/ncca/ngl/vec*.py\nsynced: " + "0" * 40 + "\n---\n" |
| 136 | + ) |
123 | 137 | status = check_sync.check_page(wiki_repo, page) |
124 | 138 | assert status.state == "error" |
125 | 139 | assert "commit" in status.message |
|
0 commit comments