mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-03 14:58:51 -06:00
refactor: keep shared test fixtures in helpers
Fifteen modules imported FakeRepository from test_install_selection, and others read fixtures from test_install_app, test_install_offline, test_install_games, test_launchers, test_prose_style, test_site_nav, test_site_pronouns and test_site_copy. Those now live in installsupport, gamessupport, launcherssupport, docpagessupport, sitepages and sitecopy, and test_layers refuses an import of a test module. sitereferencesupport and the DIST each site module defined merge into sitepages, launchersretrobatsupport into launcherssupport, auditsupport into the tests package (REPO_ROOT, HAS_JSONSCHEMA). test_launchers is the Batocera module and becomes test_launchers_batocera. test_port becomes test_handheld_port: its archive checks repeated test_handheld_scripts, whose TheArchives now holds the port.json assertions. The testing guide splits the row that held 113 modules, replaces the e2e number ranges by a module table, gives package imports and scratch_dir in How to add a test, lists every module that reads the working tree and every helper module. Its guard moves to test_doc_pages_tools and checks each module on one row once and each family on one row. The guide and tools.md join the pages whose cited paths and options are looked up.
This commit is contained in:
1 parent
b2d4eee534
commit
74ba20ac10
73 files changed
+1718
-1585
No files matched your search
@@ -371,6 +371,37 @@ class ModuleNames(unittest.TestCase):
|
||||
self.assertEqual(found, [])
|
||||
|
||||
|
||||
class TestModulesImportNoTestModule(unittest.TestCase):
|
||||
"""FakeRepository lived in test_install_selection and fifteen modules
|
||||
imported it from there: a module imported for a fixture loads its test
|
||||
classes too, and a shared fixture belongs in a helper module."""
|
||||
|
||||
@staticmethod
|
||||
def imported_test_modules(source: str) -> list[str]:
|
||||
found = []
|
||||
for node in ast.walk(ast.parse(source)):
|
||||
if isinstance(node, ast.ImportFrom) and node.module:
|
||||
names = [node.module] + [f"{node.module}.{a.name}" for a in node.names]
|
||||
elif isinstance(node, ast.Import):
|
||||
names = [a.name for a in node.names]
|
||||
else:
|
||||
continue
|
||||
found += [name for name in names if name.startswith("tests.test_")][:1]
|
||||
return found
|
||||
|
||||
def test_no_test_module_is_imported(self):
|
||||
folder = Path(__file__).resolve().parent
|
||||
found = [f"{path.name}: {name}" for path in sorted(folder.rglob("*.py"))
|
||||
for name in self.imported_test_modules(path.read_text(encoding="utf-8"))]
|
||||
self.assertEqual(found, [], "move what it shares into a helper module")
|
||||
|
||||
def test_both_forms_are_found(self):
|
||||
self.assertEqual(self.imported_test_modules("from tests.test_x import y\n"), ["tests.test_x"])
|
||||
self.assertEqual(self.imported_test_modules("import tests.test_x\n"), ["tests.test_x"])
|
||||
self.assertEqual(self.imported_test_modules("from tests import test_x\n"), ["tests.test_x"])
|
||||
self.assertEqual(self.imported_test_modules("from tests.sitepages import x\n"), [])
|
||||
|
||||
|
||||
CODE_CEILING = 800
|
||||
TEST_CEILING = 1500
|
||||
|
||||
|
||||
Reference in new issue
Block a user