refactor: guards read the code where it moved

This commit is contained in:
Abdessamad Derraz committed 2026-11-18 19:31:28 +01:00
1 parent 3af6f818d3
commit 5f7cbdc582
4 files changed
+8 -6

No files matched your search

+1 -1
View File
@@ -1063,7 +1063,7 @@ class CatalogRatioRegressions(unittest.TestCase):
def test_no_surface_counts_matches_on_its_own(self):
for relative in self._SURFACES:
tree = ast.parse((ROOT / relative).read_text(encoding="utf-8"))
tree = ast.parse(script_source(relative.removeprefix("scripts/")))
inline = [
node.lineno
for node in ast.walk(tree)
+3 -4
View File
@@ -16,7 +16,6 @@ import unittest
from sitegen import cards
from sitegen import emulatorpage
from sitegen import nav as sitegen_nav
from sitegen import parts as sitegen_parts
from sitegen import platformfiles
from sitegen import systempages
from sitegen import starlight as sitestarlight
@@ -119,13 +118,13 @@ class APlatformSystemOverItsBudgetMoves(unittest.TestCase):
files = [{"name": f"f{i:04d}.zip", "status": "ok"} for i in range(40)]
config = {("arcade", f["name"]): [{"name": f["name"], "md5": "a" * 32}] for f in files}
moved: dict[str, str] = {}
budget = sitegen_parts.PLATFORM_SECTION_BUDGET
sitegen_parts.PLATFORM_SECTION_BUDGET = 5
budget = platformfiles.PLATFORM_SECTION_BUDGET
platformfiles.PLATFORM_SECTION_BUDGET = 5
try:
lines = platformfiles._render_platform_systems(
{"arcade": files}, config, {}, ("deck", "Deck"), moved)
finally:
sitegen_parts.PLATFORM_SECTION_BUDGET = budget
platformfiles.PLATFORM_SECTION_BUDGET = budget
text = "\n".join(lines)
self.assertIn("{ #arcade }", text)
self.assertIn("](deck-arcade.md)", text)
+3
View File
@@ -15,6 +15,7 @@ parts extracted into one folder are the pack.
from __future__ import annotations
import tests
from tests.sources import script_source
import contextlib
import io
@@ -292,6 +293,8 @@ class PartsAreExplainedWhereTheyAreDownloaded(unittest.TestCase):
)
def _text(self, relative: str) -> str:
if relative.startswith("scripts/"):
return script_source(relative.removeprefix("scripts/"))
return (REPO_ROOT / relative).read_text(encoding="utf-8")
def test_every_page_names_the_parts(self):
+1 -1
View File
@@ -393,7 +393,7 @@ class TheCopyKeepsTheCheckoutOutOfReach(unittest.TestCase):
checkout = scratch_checkout()
proc = subprocess.run(
[sys.executable, "-c", "import sys; sys.path.insert(0, 'scripts'); "
"import generate_site; print(generate_site._REPO_ROOT)"],
"from sitegen import config; print(config._REPO_ROOT)"],
capture_output=True, text=True, cwd=str(checkout), timeout=300, check=True,
)
self.assertEqual(Path(proc.stdout.strip()), checkout.resolve())