diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 6b7b7babe..574d1ad84 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -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) diff --git a/tests/test_site_weight.py b/tests/test_site_weight.py index 372c689a6..01dbd44f1 100644 --- a/tests/test_site_weight.py +++ b/tests/test_site_weight.py @@ -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) diff --git a/tests/test_split_pack.py b/tests/test_split_pack.py index 6ecb30016..0715806a1 100644 --- a/tests/test_split_pack.py +++ b/tests/test_split_pack.py @@ -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): diff --git a/tests/test_system_selection.py b/tests/test_system_selection.py index 0f32614ce..a91a38025 100644 --- a/tests/test_system_selection.py +++ b/tests/test_system_selection.py @@ -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())