refactor: one owner for the test scratch folder

Test modules passed dir= the repository's tmp/ or a hard-coded tmp/tests by hand, and seven modules kept their own _tempdir copy. Under run_tests.py the literal tmp/tests did not exist in a fresh clone (FileNotFoundError in test_core_probe and scratch_checkout), and dir=tmp/ wrote beside the per-module scratch folders. Every temporary directory now lands in the folder tests/__init__ sets, and scratch_dir() replaces the copies. The X socket binds by a relative name, since a scratch path can exceed the 108-byte AF_UNIX limit. The journeys keep the short tmp/ root: their word budgets count the printed card path.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:04:40 +01:00
1 parent ec50bf6b41
commit fbbb941e38
127 files changed
+665 -826

No files matched your search

+4 -4
View File
@@ -39,7 +39,7 @@ def _report(platform: str, files: list[str], **changes: object) -> dict:
class ExportReportIsWrittenAndRead(unittest.TestCase):
def test_report_round_trips_through_the_page_loader(self):
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch:
with tempfile.TemporaryDirectory() as scratch:
report = _report("recalbox", ["es_bios.xml"])
write_report(Path(scratch) / "recalbox.json", report)
(Path(scratch) / "recalbox").mkdir()
@@ -48,7 +48,7 @@ class ExportReportIsWrittenAndRead(unittest.TestCase):
def test_a_report_goes_into_a_directory_not_yet_made(self):
"""RetroPie with nothing left to correct writes no file, so its
output directory was never made and the report crashed --all."""
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch:
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "fresh" / "retropie.json"
write_report(target, _report("retropie", []))
self.assertTrue(target.exists())
@@ -216,7 +216,7 @@ class TheRunReportStatesWhatTheFileCarries(unittest.TestCase):
"md5": "a" * 32},
]}}}
doubled = {"destination": "a.bin", "declarations": []}
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch, \
with tempfile.TemporaryDirectory() as scratch, \
mock.patch.object(native, "load_inputs",
return_value=(truth, scraped)), \
mock.patch.object(native, "unpinned", return_value=[]), \
@@ -589,7 +589,7 @@ class ADestinationDeclaredTwiceIsNamed(unittest.TestCase):
def setUp(self):
import hashlib
self._tmp = tempfile.TemporaryDirectory(dir=ROOT / "tmp")
self._tmp = tempfile.TemporaryDirectory()
root = Path(self._tmp.name)
files, by_md5, by_name = {}, {}, {}
self.md5 = {}