mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
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:
1 parent
ec50bf6b41
commit
fbbb941e38
127 files changed
+665
-826
No files matched your search
@@ -13,8 +13,10 @@ temporary directory instead of naming the missing parent.
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
os.environ.setdefault("RETROBIOS_OFFLINE", "1")
|
||||
@@ -53,3 +55,11 @@ os.environ["GIT_CEILING_DIRECTORIES"] = str(_SCRATCH)
|
||||
# The installer's cache (the games index, what reading a card found) is the
|
||||
# suite's own: a run never reads nor fills the one of the person running it.
|
||||
os.environ.setdefault("RETROBIOS_CACHE", str(_SCRATCH / "cache"))
|
||||
|
||||
|
||||
def scratch_dir(test: unittest.TestCase) -> Path:
|
||||
"""A fresh directory under this module's scratch folder, removed after
|
||||
the test."""
|
||||
path = Path(tempfile.mkdtemp())
|
||||
test.addCleanup(shutil.rmtree, path, True)
|
||||
return path
|
||||
@@ -31,7 +31,7 @@ LINKED = ("bios", "data")
|
||||
@cache
|
||||
def scratch_checkout() -> Path:
|
||||
"""The copy, built once per test process and removed at its exit."""
|
||||
root = Path(tempfile.mkdtemp(prefix="checkout-", dir=REPO_ROOT / "tmp" / "tests"))
|
||||
root = Path(tempfile.mkdtemp(prefix="checkout-"))
|
||||
# A detached worktree with nothing checked out: the scripts that read
|
||||
# HEAD (the site's bootstrap pin) find this commit.
|
||||
subprocess.run(
|
||||
|
||||
@@ -27,7 +27,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class TheAcceptedChecksumWins(unittest.TestCase):
|
||||
def setUp(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
self.old = root / "bios/Sys/GC/dsp_rom.bin"
|
||||
self.good = root / "bios/.variants/dsp_rom.bin.good"
|
||||
@@ -73,7 +73,7 @@ class TheTwoRomsFormAPairTheCodeTakes(unittest.TestCase):
|
||||
plus official coef, which its known_roms table refuses."""
|
||||
|
||||
def setUp(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
held = {
|
||||
("dsp_rom.bin", root / "bios/Sys/GC/dsp_rom.bin"): b"\x01\x02" * 8,
|
||||
|
||||
@@ -22,7 +22,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class AgnosticSubstitute(unittest.TestCase):
|
||||
def test_only_the_platform_cores_answer(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
held = Path(tmp) / "ps2" / "scph39001.bin"
|
||||
held.parent.mkdir()
|
||||
held.write_bytes(b"x" * 16)
|
||||
|
||||
@@ -15,8 +15,6 @@ from scripts.scraper import arcade_parent_importer as api
|
||||
from scripts.scraper import listxml
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "arcade_parents"
|
||||
COMMITTED = ROOT / "games" / "arcade"
|
||||
|
||||
@@ -114,7 +112,7 @@ class OfflineImport(unittest.TestCase):
|
||||
"""import_profile reads the cache only, and two runs write the same bytes."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.cache = Path(self.temp.name)
|
||||
dat = self.cache / "repo" / "libretro" / "mame2010-libretro" / COMMIT / "metadata"
|
||||
dat.mkdir(parents=True)
|
||||
@@ -256,7 +254,7 @@ class DriverSource(unittest.TestCase):
|
||||
the DATs those repositories carry contradict it."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.cache = Path(self.temp.name)
|
||||
slug = "libretro/mame2003-libretro"
|
||||
tarball = self.cache / "src" / slug / f"{COMMIT}.tar.gz"
|
||||
@@ -417,7 +415,7 @@ class CommittedIndex(unittest.TestCase):
|
||||
import validate_schemas
|
||||
|
||||
self.assertEqual(validate_schemas._arcade_pin_errors(), [])
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
(root / "games" / "arcade").mkdir(parents=True)
|
||||
(root / "emulators").mkdir()
|
||||
|
||||
@@ -24,8 +24,6 @@ from romrecipes import ledger
|
||||
from core.torrentzip import build_torrentzip
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
ROM_A = b"first rom payload" * 50
|
||||
ROM_B = b"second rom payload" * 40
|
||||
@@ -112,7 +110,7 @@ class Fixture(unittest.TestCase):
|
||||
"""A small collection: a loose ROM, a TorrentZip set, a plain ZIP."""
|
||||
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.temp.name)
|
||||
bios = self.root / "bios"
|
||||
bios.mkdir()
|
||||
|
||||
@@ -187,7 +187,7 @@ class TheArchiveHoldingTheCoreMembers(unittest.TestCase):
|
||||
start a Neo Geo CD game."""
|
||||
|
||||
def setUp(self):
|
||||
directory = tempfile.mkdtemp(dir=REPO_ROOT / "tmp")
|
||||
directory = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, directory, True)
|
||||
root = Path(directory)
|
||||
self.roms = {"neocd.bin": b"bios" * 8, "000-lo.lo": b"zoom" * 8}
|
||||
@@ -358,7 +358,7 @@ class AnArchiveHashedByItsMembers(unittest.TestCase):
|
||||
archive's name: Recalbox cannot open it and reports the BIOS red."""
|
||||
|
||||
def setUp(self):
|
||||
directory = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
directory = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, directory, True)
|
||||
rom = b"bios" * 8
|
||||
raw = directory / "bios/neocd.bin"
|
||||
@@ -408,7 +408,7 @@ class AnArchiveRankedByWhatItHolds(unittest.TestCase):
|
||||
unrelated duplicate was deleted and the index order flipped."""
|
||||
|
||||
def setUp(self):
|
||||
directory = tempfile.mkdtemp(dir=REPO_ROOT / "tmp")
|
||||
directory = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, directory, True)
|
||||
self.root = Path(directory)
|
||||
self.roms = {f"epr-213{n}.ic27": bytes([n]) * 16 for n in (29, 30, 31, 32)}
|
||||
@@ -529,8 +529,7 @@ class ALooseEntryNamingItsArchive(unittest.TestCase):
|
||||
from packs.emulatorcheck import verify_emulator
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
@@ -579,8 +578,7 @@ class AnotherEmulatorsOwnSet(unittest.TestCase):
|
||||
copy."""
|
||||
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
+11
-23
@@ -8,6 +8,7 @@ ZIPs, which surfaces as BadZipFile far from its cause.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import scratch_dir
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
@@ -31,22 +32,9 @@ from unittest import mock
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
def _tempdir(test: unittest.TestCase) -> str:
|
||||
"""A scratch directory under the repository's tmp/, removed after the test.
|
||||
|
||||
The system temp directory is a RAM disk here, and directories left by
|
||||
every run piled up on it.
|
||||
"""
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
path = tempfile.mkdtemp(dir=str(scratch))
|
||||
test.addCleanup(shutil.rmtree, path, True)
|
||||
return path
|
||||
|
||||
|
||||
class ArtifactLockTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = _tempdir(self)
|
||||
self.dir = str(scratch_dir(self))
|
||||
|
||||
def test_writer_excludes_writer(self):
|
||||
with artifact_lock(self.dir), self.assertRaises(ArtifactLockBusy), artifact_lock(self.dir):
|
||||
@@ -96,7 +84,7 @@ class ArtifactLockTest(unittest.TestCase):
|
||||
pass
|
||||
|
||||
def test_separate_directories_do_not_contend(self):
|
||||
other = _tempdir(self)
|
||||
other = str(scratch_dir(self))
|
||||
with artifact_lock(self.dir), artifact_lock(other):
|
||||
pass
|
||||
|
||||
@@ -110,7 +98,7 @@ class PackLockCliTest(unittest.TestCase):
|
||||
"""generate_pack and pipeline must refuse a directory held elsewhere."""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = _tempdir(self)
|
||||
self.dir = str(scratch_dir(self))
|
||||
|
||||
def _run(self, argv: list[str]) -> subprocess.CompletedProcess:
|
||||
# In a copy: a pipeline that missed the lock regenerated
|
||||
@@ -235,7 +223,7 @@ class PipelineHoldsItsFixedOutputs(unittest.TestCase):
|
||||
install/, README.md and docs/: only the output directory was locked."""
|
||||
|
||||
def test_a_second_pipeline_is_refused_whatever_its_output_dir(self):
|
||||
scratch = _tempdir(self)
|
||||
scratch = str(scratch_dir(self))
|
||||
checkout = scratch_checkout()
|
||||
with hold_repository_outputs(str(checkout)):
|
||||
proc = subprocess.run(
|
||||
@@ -260,7 +248,7 @@ class TheSuiteTakesTheRepositoryHoldInItsScratch(unittest.TestCase):
|
||||
a generator writing database.json, failed on the busy lock."""
|
||||
|
||||
def test_the_hold_is_taken_where_the_variable_says(self):
|
||||
scratch = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
scratch = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, scratch, True)
|
||||
moved = scratch / "repository-lock"
|
||||
with mock.patch.dict(os.environ, {artifacts.REPOSITORY_LOCK_ENV: str(moved)}), \
|
||||
@@ -273,7 +261,7 @@ class TheSuiteTakesTheRepositoryHoldInItsScratch(unittest.TestCase):
|
||||
pass
|
||||
|
||||
def test_another_directory_keeps_its_own_lock(self):
|
||||
out = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
out = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, out, True)
|
||||
with mock.patch.dict(os.environ, {artifacts.REPOSITORY_LOCK_ENV: str(out / "x")}), \
|
||||
artifacts.artifact_lock(str(out)):
|
||||
@@ -324,14 +312,14 @@ class StandaloneWritersHonourTheRepositoryHold(unittest.TestCase):
|
||||
def test_a_step_the_pipeline_spawns_passes(self):
|
||||
"""A pipeline holds the root and its --output-dir, and its steps
|
||||
write both: the environment names the two, os.pathsep apart."""
|
||||
self.scratch = _tempdir(self)
|
||||
self.scratch = str(scratch_dir(self))
|
||||
with hold_repository_outputs(str(REPO_ROOT)), publish_hold(str(REPO_ROOT)), \
|
||||
hold_artifact_lock(self.scratch):
|
||||
proc = self._child(str(REPO_ROOT / "install" / "games"), dict(os.environ))
|
||||
self.assertEqual(proc.returncode, 0, proc.stderr)
|
||||
|
||||
def test_a_scratch_output_takes_nothing(self):
|
||||
self.scratch = _tempdir(self)
|
||||
self.scratch = str(scratch_dir(self))
|
||||
env = {k: v for k, v in os.environ.items() if k != "RETROBIOS_HELD_ARTIFACT_DIR"}
|
||||
with hold_repository_outputs(str(REPO_ROOT)):
|
||||
proc = self._child(os.path.join(self.scratch, "database.json"), env)
|
||||
@@ -344,7 +332,7 @@ class HeldLockTest(unittest.TestCase):
|
||||
check reported every platform SKIP and passed."""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = _tempdir(self)
|
||||
self.dir = str(scratch_dir(self))
|
||||
|
||||
def _child_locks(self, env: dict) -> subprocess.CompletedProcess:
|
||||
code = (
|
||||
@@ -396,7 +384,7 @@ class SiteGenerationHoldsDocs(unittest.TestCase):
|
||||
the same tree. That run then died on os.replace or lost pages."""
|
||||
|
||||
def test_a_second_run_is_refused_before_it_writes(self):
|
||||
docs = _tempdir(self)
|
||||
docs = str(scratch_dir(self))
|
||||
marker = Path(docs) / "platforms" / ".retroarch.md.k2j3.tmp"
|
||||
marker.parent.mkdir()
|
||||
marker.write_text("scratch of another run")
|
||||
|
||||
@@ -148,7 +148,7 @@ class TheNativeIndexKeepsEveryPlatform(unittest.TestCase):
|
||||
|
||||
from exporter.originals import SOURCES_INDEX, fetch
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
index = root / SOURCES_INDEX
|
||||
|
||||
@@ -338,7 +338,7 @@ class ATerminatedBuildLeavesNoScratch(unittest.TestCase):
|
||||
|
||||
if not hasattr(signal, "SIGTERM") or os.name != "posix":
|
||||
self.skipTest("POSIX signals")
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
pack = Path(tmp) / "Demo_BIOS_Pack.zip"
|
||||
child = subprocess.Popen(
|
||||
[sys.executable, "-c", self.CHILD, str(pack)], cwd=REPO_ROOT,
|
||||
|
||||
@@ -40,8 +40,6 @@ from scripts.packs.targets import generate_target_manifests
|
||||
|
||||
HAS_JSONSCHEMA = jsonschema is not None
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
class ReadmeRegressions(unittest.TestCase):
|
||||
@@ -233,7 +231,7 @@ class AModuleRunAloneHasItsScratchDirectory(unittest.TestCase):
|
||||
fresh clone raised FileNotFoundError. The test package creates it."""
|
||||
|
||||
def test_importing_the_package_creates_tmp(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
clone = Path(directory)
|
||||
(clone / "tests").mkdir()
|
||||
(clone / "tests" / "__init__.py").write_bytes(
|
||||
@@ -628,7 +626,7 @@ class APackIsSwappedInWhole(unittest.TestCase):
|
||||
import tempfile
|
||||
|
||||
(ROOT / "tmp").mkdir(exist_ok=True)
|
||||
directory = Path(tempfile.mkdtemp(dir=ROOT / "tmp"))
|
||||
directory = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, directory, True)
|
||||
return directory
|
||||
|
||||
@@ -835,7 +833,7 @@ class ADamagedArchiveIsNotPacked(unittest.TestCase):
|
||||
|
||||
from packs.archive import DamagedArchiveError, add_zip_to_pack
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
source = Path(directory) / "set.zip"
|
||||
with zipfile.ZipFile(source, "w", zipfile.ZIP_STORED) as zf:
|
||||
zf.writestr("rom.bin", b"A" * 64)
|
||||
@@ -861,7 +859,7 @@ class APackedArchiveKeepsItsBytes(unittest.TestCase):
|
||||
|
||||
from packs.archive import add_zip_to_pack
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
source = Path(directory) / "set.zip"
|
||||
with zipfile.ZipFile(source, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
zf.writestr(zipfile.ZipInfo("rom.bin", (1999, 1, 2, 3, 4, 5)), b"rom" * 40)
|
||||
@@ -949,7 +947,7 @@ class AutoFetchReadsListsAndPlacesWithoutClobbering(unittest.TestCase):
|
||||
def test_the_review_folder_is_used_and_nothing_is_overwritten(self):
|
||||
from scripts.acquire import fetch as acquire_fetch
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
bios = Path(directory)
|
||||
for folder in ("Nintendo/SNES", "Nintendo/N64", "Nintendo/Nintendo 64DD"):
|
||||
(bios / folder).mkdir(parents=True)
|
||||
@@ -1427,7 +1425,7 @@ class ResolverRegressions(unittest.TestCase):
|
||||
}
|
||||
|
||||
def test_hash_identity_wins_over_wrong_destination_hint(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
wrong = root / "wrong" / "firmware.bin"
|
||||
correct = root / "correct" / "firmware.bin"
|
||||
@@ -1449,7 +1447,7 @@ class ResolverRegressions(unittest.TestCase):
|
||||
self.assertEqual(status, "sha1_exact")
|
||||
|
||||
def test_name_cannot_mask_a_declared_hash_mismatch(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "firmware.bin"
|
||||
path.write_bytes(b"wrong")
|
||||
db = self._database({"firmware.bin": path})
|
||||
@@ -1480,7 +1478,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
from scripts.resolve.validation import baseline_verdict
|
||||
|
||||
entry = {"name": "dragon32.zip", "zipped_file": "d32.rom", "md5": ""}
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = self._archive(Path(directory), "other.rom")
|
||||
status, refusal = baseline_verdict(entry, path, "name_exact", "md5")
|
||||
self.assertEqual(refusal, "d32.rom not found inside ZIP")
|
||||
@@ -1499,7 +1497,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
from scripts.packs.integrity import _intentional_hash_exclusion
|
||||
|
||||
entry = {"name": "dragon32.zip", "zipped_file": "d32.rom", "md5": ""}
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = self._archive(Path(directory), "other.rom")
|
||||
sha1 = hashlib.sha1(Path(path).read_bytes()).hexdigest()
|
||||
db = {"files": {sha1: {"path": path, "name": "dragon32.zip", "sha1": sha1}},
|
||||
@@ -1521,7 +1519,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
from scripts.core.hashing import md5_composite
|
||||
from scripts.resolve.validation import baseline_verdict, digest_verdict
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
loose = Path(directory) / "abc.bin"
|
||||
loose.write_bytes(b"abc")
|
||||
md5 = hashlib.md5(b"abc").hexdigest()
|
||||
@@ -1551,7 +1549,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
from scripts.core.hashing import md5_composite
|
||||
from scripts.resolve.validation import digest_verdict
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
archive = self._archive(Path(directory), "rom.bin")
|
||||
raw = hashlib.md5(Path(archive).read_bytes()).hexdigest()
|
||||
members = md5_composite(archive)
|
||||
@@ -1615,7 +1613,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
from resolve import packfiles as packresolve
|
||||
from scripts.packs.coverage import _resolve_for_platform
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
cached = Path(directory) / "BIG.PUP"
|
||||
cached.write_bytes(b"large firmware")
|
||||
sha1 = hashlib.sha1(cached.read_bytes()).hexdigest()
|
||||
@@ -1635,7 +1633,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
|
||||
class PackExclusionRegressions(unittest.TestCase):
|
||||
def test_slug_platform_core_requirement_uses_the_generated_destination(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
platforms = root / "platforms"
|
||||
platforms.mkdir()
|
||||
@@ -1763,7 +1761,7 @@ class PackExclusionRegressions(unittest.TestCase):
|
||||
|
||||
def test_hash_platform_accounts_for_an_unsafe_exclusion(self):
|
||||
"""A platform that reads the bytes would reject the local payload."""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
database, platforms = self._mismatch_fixture(root, "md5")
|
||||
pack = root / "pack.zip"
|
||||
@@ -1787,7 +1785,7 @@ class PackExclusionRegressions(unittest.TestCase):
|
||||
An upstream hash the local dump contradicts must not remove a file the
|
||||
frontend would have loaded, so its absence stays a conformance error.
|
||||
"""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
database, platforms = self._mismatch_fixture(root, "existence")
|
||||
pack = root / "pack.zip"
|
||||
@@ -1806,7 +1804,7 @@ class PackExclusionRegressions(unittest.TestCase):
|
||||
self.assertEqual(result[8], 0)
|
||||
|
||||
def test_unexplained_missing_file_still_fails_conformance(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
platforms = root / "platforms"
|
||||
platforms.mkdir()
|
||||
@@ -1927,7 +1925,7 @@ class RegionRegressions(unittest.TestCase):
|
||||
identified by its path (Dolphin's three IPL.bin) was never checked."""
|
||||
import hashlib
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
previous = os.getcwd()
|
||||
os.chdir(directory)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
@@ -1960,7 +1958,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
return directory / name
|
||||
|
||||
def test_member_count_limit_is_enforced(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
with zipfile.ZipFile(archive, "w") as handle:
|
||||
@@ -1973,7 +1971,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
"""Every member came out 0600, the mode of its temporary file: the
|
||||
pico8 and vox launchers the RetroDECK pack keeps 0755 lost their
|
||||
execute bit once download.py extracted them."""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
program = zipfile.ZipInfo("pico8")
|
||||
@@ -1994,7 +1992,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
self.assertEqual((root / "out" / "bios.bin").stat().st_mode & 0o777, 0o644)
|
||||
|
||||
def test_symlink_member_is_rejected(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
link = zipfile.ZipInfo("link")
|
||||
@@ -2011,7 +2009,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
download.py feeds third-party archives to this function, so a legal
|
||||
Windows path must extract into a subdirectory instead of failing.
|
||||
"""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
with zipfile.ZipFile(archive, "w") as handle:
|
||||
@@ -2021,7 +2019,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
self.assertEqual((out / "sub" / "rom.bin").read_bytes(), b"payload")
|
||||
|
||||
def test_windows_separator_cannot_smuggle_traversal(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
with zipfile.ZipFile(archive, "w") as handle:
|
||||
@@ -2031,7 +2029,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
|
||||
def test_high_ratio_method_is_bounded_by_size_not_ratio(self):
|
||||
"""bzip2 legitimately exceeds the DEFLATE ceiling."""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
with zipfile.ZipFile(archive, "w", zipfile.ZIP_BZIP2) as handle:
|
||||
@@ -2041,7 +2039,7 @@ class ArchiveSecurityRegressions(unittest.TestCase):
|
||||
self.assertEqual((out / "zeros.bin").stat().st_size, 4_000_000)
|
||||
|
||||
def test_compression_ratio_limit_is_enforced(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
archive = self._zip_path(root)
|
||||
with zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) as handle:
|
||||
@@ -2165,7 +2163,7 @@ class InstallerBoundaryRegressions(unittest.TestCase):
|
||||
"""
|
||||
import validate_schemas
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
dist = Path(directory)
|
||||
broken = {
|
||||
"schema_version": 1,
|
||||
@@ -2207,7 +2205,7 @@ class InstallerBoundaryRegressions(unittest.TestCase):
|
||||
document, scope.pack_systems(install_list, targets))
|
||||
self.assertIn("install_list", document)
|
||||
self.assertIn("targets", document)
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
dist = Path(directory)
|
||||
with zipfile.ZipFile(dist / "Pack.zip", "w") as archive:
|
||||
archive.writestr("manifest.json", json.dumps(document))
|
||||
@@ -2241,7 +2239,7 @@ class InstallerBoundaryRegressions(unittest.TestCase):
|
||||
|
||||
class TargetManifestRegressions(unittest.TestCase):
|
||||
def test_yaml_scalar_core_is_rejected_instead_of_leaking_to_json(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
source = root / "source"
|
||||
output = root / "output"
|
||||
@@ -2281,7 +2279,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
|
||||
def test_restore_matches_assets_by_content_not_by_name(self):
|
||||
from scripts.release.restore import restore
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
cache = root / "cache"
|
||||
cache.mkdir()
|
||||
@@ -2316,7 +2314,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
|
||||
|
||||
from scripts.release.restore import gitignored_paths
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
missing = str(Path(directory) / "absent")
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
gitignored_paths(missing)
|
||||
@@ -2335,7 +2333,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
|
||||
database pins to the old ones."""
|
||||
from scripts.release import restore as release_restore
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
cache = root / "cache"
|
||||
cache.mkdir()
|
||||
@@ -2370,7 +2368,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
|
||||
def test_restore_leaves_tracked_paths_alone(self):
|
||||
from scripts.release.restore import restore
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
cache = root / "cache"
|
||||
cache.mkdir()
|
||||
@@ -2398,7 +2396,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
|
||||
gitignored file absent: the early return ran before the check."""
|
||||
from scripts.release.restore import restore
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / ".gitignore").write_text("bios/big.bin\n", encoding="utf-8")
|
||||
(root / "database.json").write_text(
|
||||
@@ -2473,7 +2471,7 @@ class ManifestVersionIsThePlatformsOwn(unittest.TestCase):
|
||||
|
||||
def test_an_unversioned_child_has_no_version(self):
|
||||
from scripts.model.platforms import load_platform_config
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "parent.yml").write_text("platform: P\nversion: '2.0'\nsystems: {}\n")
|
||||
Path(tmp, "child.yml").write_text("inherits: parent\nplatform: C\n")
|
||||
self.assertNotIn("version", load_platform_config("child", tmp))
|
||||
@@ -2687,7 +2685,7 @@ class ReleaseAssetCriterion(unittest.TestCase):
|
||||
def test_a_large_committed_file_is_served_by_the_repository(self):
|
||||
from scripts.packs import manifestentry
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = self._repo(directory, "bios/elsewhere.bin")
|
||||
big = Path(root, "bios", "big.avi")
|
||||
big.parent.mkdir()
|
||||
@@ -2704,7 +2702,7 @@ class ReleaseAssetCriterion(unittest.TestCase):
|
||||
# name while the manifest gave install.py the spaced one, a 404.
|
||||
from scripts.packs import manifestentry
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = self._repo(directory, "bios/MAME/MAME 0.174 Arcade XML.dat")
|
||||
target = Path(root, "bios", "MAME", "MAME 0.174 Arcade XML.dat")
|
||||
target.parent.mkdir(parents=True)
|
||||
@@ -2721,7 +2719,7 @@ class ReleaseAssetCriterion(unittest.TestCase):
|
||||
def test_a_gitignored_file_is_served_by_the_release_whatever_its_size(self):
|
||||
from scripts.packs import manifestentry
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = self._repo(directory, "bios/small.zip")
|
||||
small = Path(root, "bios", "small.zip")
|
||||
small.parent.mkdir()
|
||||
@@ -2882,7 +2880,7 @@ class OneRefreshPerOnlineRun(unittest.TestCase):
|
||||
|
||||
# A scratch output directory: step 4 purges the ZIPs of the one it
|
||||
# is given, and this run must never touch dist/.
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as out, \
|
||||
with tempfile.TemporaryDirectory() as out, \
|
||||
mock.patch.object(pipeline, "run", record), \
|
||||
mock.patch.object(
|
||||
sys, "argv", ["pipeline.py", "--skip-docs", "--output-dir", out]
|
||||
@@ -3210,7 +3208,7 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def test_naming_a_platform_with_no_pack_is_not_a_pass(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
named = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--platform",
|
||||
"retroarch", "--verify-packs", "--output-dir", directory],
|
||||
@@ -3236,7 +3234,7 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
|
||||
def test_an_unsatisfiable_declared_path_is_reported(self):
|
||||
from scripts.release.restore import restore
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
cache = root / "cache"
|
||||
cache.mkdir()
|
||||
@@ -3487,7 +3485,7 @@ class ARegionDroppedExtraBlocksNothing(unittest.TestCase):
|
||||
|
||||
from scripts.packs import extras as packextras
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
other = Path(directory) / "FOO.ROM"
|
||||
other.write_bytes(b"other bytes")
|
||||
first = Path(directory) / "foo.rom"
|
||||
@@ -3541,7 +3539,7 @@ class AnotherEmulatorsTreeProvesNothing(unittest.TestCase):
|
||||
def test_neither_the_full_tail_nor_the_name_lands_in_a_foreign_tree(self):
|
||||
from scripts.resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
# The collection's layout, read relative to its root.
|
||||
previous = os.getcwd()
|
||||
@@ -3628,7 +3626,7 @@ class ANameWithItsDirectoryIsTheDestination(unittest.TestCase):
|
||||
|
||||
from scripts.resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
@@ -3661,7 +3659,7 @@ class AnUnreadableDatabaseStopsTheScan(unittest.TestCase):
|
||||
|
||||
from scripts import generate_db
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "database.json"
|
||||
path.write_text("<<<<<<< HEAD\n{}\n")
|
||||
with mock.patch.object(generate_db, "_load_gitignored_large_files",
|
||||
@@ -3684,7 +3682,7 @@ class TheZipIndexCacheKnowsItsInputs(unittest.TestCase):
|
||||
def test_the_bound_and_the_sha1_are_part_of_the_key(self):
|
||||
from scripts.core import ziptools
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "a.zip"
|
||||
with zipfile.ZipFile(path, "w") as archive:
|
||||
archive.writestr("big.bin", b"x" * 4096)
|
||||
@@ -3715,7 +3713,7 @@ class GeneratedModelsAreWrittenWhole(unittest.TestCase):
|
||||
def test_an_unreadable_clone_map_stops_the_run(self):
|
||||
from scripts import dedup
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
bios = root / "bios"
|
||||
# A device clone: two archive names, the same ROMs, in MAME's tree.
|
||||
@@ -3740,7 +3738,7 @@ class APackNoteBesideItsSlotIsANote(unittest.TestCase):
|
||||
def test_a_nested_note_is_not_hashed_against_the_collection(self):
|
||||
from scripts.packs.integrity import verify_pack
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "Pack.zip"
|
||||
with zipfile.ZipFile(path, "w") as archive:
|
||||
archive.writestr("games/keen6/INSTRUCTIONS_egagraph.ck6.txt", "File needed")
|
||||
@@ -3811,7 +3809,7 @@ class TheDatabaseCacheIsWrittenWhole(unittest.TestCase):
|
||||
|
||||
from scripts import generate_db
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = os.path.join(directory, "cache", "db_cache.json")
|
||||
generate_db.save_cache(path, {"a": 1})
|
||||
with mock.patch.object(json, "dumps", side_effect=TypeError("miscomputed")), \
|
||||
@@ -3929,7 +3927,7 @@ class HashMergeBackupsAreNotSources(unittest.TestCase):
|
||||
except ImportError as exc:
|
||||
self.skipTest(f"validate_schemas needs jsonschema: {exc}")
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
(Path(directory) / "mame.old.yml").write_text("emulator: [\n")
|
||||
self.assertEqual(
|
||||
_validate_yaml_directory(Path(directory), "emulator.schema.json"), []
|
||||
@@ -3953,7 +3951,7 @@ class AnUnreadableArchiveIsSaidOutLoud(unittest.TestCase):
|
||||
def test_the_resolver_names_the_archive(self):
|
||||
from resolve import localfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
broken = Path(tmp) / "neogeo.zip"
|
||||
broken.write_bytes(b"PK\x03\x04 truncated")
|
||||
sha1 = hashlib.sha1(broken.read_bytes()).hexdigest()
|
||||
@@ -4043,7 +4041,7 @@ class ADataDirectoryIsWalkedOnce(unittest.TestCase):
|
||||
def test_two_lookups_share_one_walk_and_keep_its_order(self):
|
||||
from resolve.datadirs import forget_data_dir_index, resolve_in_data_dirs
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache = Path(tmp) / "cache"
|
||||
(cache / "a").mkdir(parents=True)
|
||||
(cache / "b").mkdir()
|
||||
@@ -4104,7 +4102,7 @@ class AnAcceptedVersionIsNoCoreDiscrepancy(unittest.TestCase):
|
||||
def test_a_sibling_version_matches(self):
|
||||
from scripts.packs.platformpack import _matches_an_alternative
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
held = Path(tmp) / "NWINTER.GRP"
|
||||
held.write_bytes(b"demo")
|
||||
profile = json.loads(json.dumps(self.PROFILE))
|
||||
@@ -4115,7 +4113,7 @@ class AnAcceptedVersionIsNoCoreDiscrepancy(unittest.TestCase):
|
||||
def test_a_copy_no_entry_declares_still_disagrees(self):
|
||||
from scripts.packs.platformpack import _matches_an_alternative
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
held = Path(tmp) / "NWINTER.GRP"
|
||||
held.write_bytes(b"other")
|
||||
profile = json.loads(json.dumps(self.PROFILE))
|
||||
@@ -4134,7 +4132,7 @@ class ADataDirectoryCopyPassesTheNameChecks(unittest.TestCase):
|
||||
was returned without either check."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(self.tmp, True))
|
||||
cache = self.tmp / "cache"
|
||||
cache.mkdir()
|
||||
@@ -4164,7 +4162,7 @@ class AMameCloneNameIsANameStep(unittest.TestCase):
|
||||
parent set."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(self.tmp, True))
|
||||
bios = self.tmp / "bios" / "Arcade"
|
||||
bios.mkdir(parents=True)
|
||||
@@ -4307,7 +4305,7 @@ class VerifyStrictAppliesInEveryMode(unittest.TestCase):
|
||||
def setUpClass(cls):
|
||||
if not (ROOT / "database.json").exists():
|
||||
raise unittest.SkipTest("database.json is not built")
|
||||
cls.dir = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
cls.dir = Path(tempfile.mkdtemp())
|
||||
(cls.dir / "fakeemu.yml").write_text(
|
||||
"emulator: FakeEmu\ntype: libretro\nsystems: [zz-console]\nfiles:\n"
|
||||
" - name: does_not_exist_strict.bin\n required: true\n"
|
||||
@@ -4377,7 +4375,7 @@ class ASameNamedMemberIsNotTheFile(unittest.TestCase):
|
||||
def test_a_declared_hash_decides_a_member_or_data_hit(self):
|
||||
from scripts.packs import crossref
|
||||
|
||||
tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(tmp, True))
|
||||
(tmp / "data").mkdir()
|
||||
(tmp / "data" / "font.ttf").write_bytes(b"DATA FONT")
|
||||
@@ -4404,7 +4402,7 @@ class AnEmptyTargetIsNotEveryCore(unittest.TestCase):
|
||||
from scripts.model.targets import load_target_config
|
||||
from scripts.packs.targets import generate_target_manifests
|
||||
|
||||
tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(tmp, True))
|
||||
targets = tmp / "platforms" / "targets"
|
||||
targets.mkdir(parents=True)
|
||||
@@ -4431,7 +4429,7 @@ class ADataDirectoryIsHeldWhileRead(unittest.TestCase):
|
||||
died on FileNotFoundError, or shipped bytes nobody had verified."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(self.tmp, True))
|
||||
|
||||
def test_the_index_follows_a_swapped_tree(self):
|
||||
@@ -4509,8 +4507,8 @@ class EachRootReadsItsOwnRegistry(unittest.TestCase):
|
||||
def test_two_roots_in_one_process(self):
|
||||
from scripts.packs import manifestentry
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as a, \
|
||||
tempfile.TemporaryDirectory(dir=TMP_ROOT) as b:
|
||||
with tempfile.TemporaryDirectory() as a, \
|
||||
tempfile.TemporaryDirectory() as b:
|
||||
Path(a, ".gitignore").write_text("bios/one.bin\n")
|
||||
Path(b, ".gitignore").write_text("bios/two.bin\n")
|
||||
self.assertTrue(manifestentry._is_release_asset(str(Path(a, "bios/one.bin")), a))
|
||||
@@ -5013,7 +5011,7 @@ class AManifestHashesAFileOnce(unittest.TestCase):
|
||||
def test_verified_hashes_are_reused(self):
|
||||
from scripts.packs import manifestentry
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp, "a.bin")
|
||||
path.write_bytes(b"abc")
|
||||
sha1 = hashlib.sha1(b"abc").hexdigest()
|
||||
@@ -5041,7 +5039,7 @@ class AZipMemberIsHashedOnce(unittest.TestCase):
|
||||
def test_repeated_questions_read_the_archive_once(self):
|
||||
from scripts.core import ziptools
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
archive = Path(tmp, "set.zip")
|
||||
with zipfile.ZipFile(archive, "w") as zf:
|
||||
zf.writestr("ROM.bin", b"abc")
|
||||
@@ -5088,7 +5086,7 @@ class TargetListsReadThePinnedRelease(unittest.TestCase):
|
||||
def test_the_revision_comes_from_the_platform_yaml(self):
|
||||
from scripts.scraper.targets import BaseTargetScraper
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for name, source, tag in (
|
||||
("a", "https://raw.githubusercontent.com/o/r/batocera-43.1/x/y", "batocera-43.1"),
|
||||
("b", "https://gitlab.com/recalbox/recalbox/-/raw/10.1.1/a/b.xml", "10.1.1"),
|
||||
@@ -5167,7 +5165,7 @@ class ATreeNobodyHoldsIsMissingNotAnAsset(unittest.TestCase):
|
||||
(None, "not_found"),
|
||||
)
|
||||
self.assertIsNone(largefiles.fetch_large_file("caesar3/", offline=True))
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "sub").mkdir()
|
||||
self.assertIsNone(largefiles._fetch_asset("sub", tmp, "", "", offline=True))
|
||||
|
||||
@@ -5521,7 +5519,7 @@ class BundledFilesAreNotToSource(unittest.TestCase):
|
||||
|
||||
from model.profiles import installed_data_refs
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "dolphin.yml").write_text(_yaml.safe_dump({
|
||||
"emulator": "Dolphin", "type": "libretro", "files": [],
|
||||
"data_directories": [{"ref": "dolphin-sys", "installed_on": ["lakka"]}]}))
|
||||
@@ -5865,7 +5863,7 @@ class SitemapDatesComeFromThePage(unittest.TestCase):
|
||||
saved = dict(sitegen_descriptions.PAGE_DATA)
|
||||
self.addCleanup(lambda: (sitegen_descriptions.PAGE_DATA.clear(),
|
||||
sitegen_descriptions.PAGE_DATA.update(saved)))
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
docs = Path(tmp)
|
||||
(docs / "emulators").mkdir()
|
||||
(docs / "emulators" / "dated.md").write_text("# Dated\n\nA page with its own date.\n")
|
||||
@@ -6007,7 +6005,7 @@ class ZippedFileMd5IsParsedOnce(unittest.TestCase):
|
||||
from scripts.resolve.validation import inner_rom_check
|
||||
from scripts.packs.verdicts import verify_entry_md5
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
archive = Path(directory, "x.zip")
|
||||
with zf_mod.ZipFile(archive, "w") as zf:
|
||||
zf.writestr("rom.bin", b"rom")
|
||||
@@ -6140,7 +6138,7 @@ class AProfilePathIsTheEmulatorsNotOurs(unittest.TestCase):
|
||||
except ImportError as exc:
|
||||
self.skipTest(f"validate_schemas needs jsonschema: {exc}")
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
emulators = Path(directory) / "emulators"
|
||||
emulators.mkdir()
|
||||
(emulators / "x.yml").write_text(
|
||||
@@ -6229,7 +6227,7 @@ class ANamedPackThatIsAbsentFails(unittest.TestCase):
|
||||
"SKIP" and exited 1: a skip label on a failure, and no next step."""
|
||||
|
||||
def test_the_line_says_fail_and_how_to_build(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--platform", "retroarch",
|
||||
"--verify-packs", "--output-dir", directory],
|
||||
@@ -6243,7 +6241,7 @@ class ANamedPackThatIsAbsentFails(unittest.TestCase):
|
||||
def test_all_with_no_pack_is_a_failure(self):
|
||||
"""--all on a mistyped or purged directory skipped every platform
|
||||
and exited 0, a passed integrity check that checked nothing."""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--all",
|
||||
"--verify-packs", "--output-dir", directory],
|
||||
@@ -6383,7 +6381,7 @@ class TheRepairCommandWritesTheFileNamed(unittest.TestCase):
|
||||
def test_the_command_names_the_path(self):
|
||||
from scripts.model.database import DatabaseUnreadable, load_database
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
target = str(Path(directory) / "nosuch.json")
|
||||
with self.assertRaises(DatabaseUnreadable) as caught:
|
||||
load_database(target)
|
||||
@@ -6398,7 +6396,7 @@ class TheRepairCommandWritesTheFileNamed(unittest.TestCase):
|
||||
collection into a second file named after the typo."""
|
||||
from scripts.model.database import DatabaseUnreadable, load_database
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
(Path(directory) / "database.json").write_text("{}")
|
||||
typo = Path(directory) / "databse.json"
|
||||
with self.assertRaises(DatabaseUnreadable) as caught:
|
||||
@@ -6420,7 +6418,7 @@ class VerifyPacksRefusesWhatItCannotDo(unittest.TestCase):
|
||||
["--verify-packs", "--platform", "retroarch", "--one-per-slot"],
|
||||
)
|
||||
for extra in cases:
|
||||
with self.subTest(args=extra), tempfile.TemporaryDirectory(dir=TMP_ROOT) as out:
|
||||
with self.subTest(args=extra), tempfile.TemporaryDirectory() as out:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", *extra, "--output-dir", out],
|
||||
cwd=ROOT, capture_output=True, text=True, timeout=300,
|
||||
@@ -6716,7 +6714,7 @@ class ThePackCheckAppliesTheFrontendRule(unittest.TestCase):
|
||||
"sha1": hashlib.sha1(payload).hexdigest(),
|
||||
"size": len(payload),
|
||||
}
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
pack = Path(tmp) / "p.zip"
|
||||
with zipfile.ZipFile(pack, "w") as zf:
|
||||
zf.writestr("bios/x.bin", payload)
|
||||
@@ -6735,7 +6733,7 @@ class ABrokenRegistryIsNotAnEmptyOne(unittest.TestCase):
|
||||
def test_both_raise(self):
|
||||
from scripts.model.registry import list_registered_platforms
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
list_registered_platforms(tmp)
|
||||
Path(tmp, "_registry.yml").write_text(
|
||||
@@ -7103,7 +7101,7 @@ class WhatOnlyAnInstallProvidesIsListed(unittest.TestCase):
|
||||
|
||||
import bundled_only
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp, \
|
||||
with tempfile.TemporaryDirectory() as tmp, \
|
||||
mock.patch.object(bundled_only, "list_registered_platforms", return_value=[]):
|
||||
def entry(sha1, name):
|
||||
path = Path(tmp, name)
|
||||
@@ -7137,7 +7135,7 @@ class WhatOnlyAnInstallProvidesIsListed(unittest.TestCase):
|
||||
|
||||
import bundled_only
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for name in ("dir1/a.bmp", "dir2/a.bmp", "dir2/b.bmp"):
|
||||
Path(tmp, name).parent.mkdir(exist_ok=True)
|
||||
Path(tmp, name).write_bytes(b"same" if "a.bmp" in name else b"diff")
|
||||
@@ -7213,7 +7211,7 @@ class RequiredOnlyReachesDataDirectories(unittest.TestCase):
|
||||
from scripts.packs import datatrees
|
||||
from scripts.packs.archive import Placed
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for key in ("needed", "optional"):
|
||||
Path(tmp, key).mkdir()
|
||||
Path(tmp, key, f"{key}.bin").write_bytes(b"x")
|
||||
@@ -7288,7 +7286,7 @@ class InstallerJsonKindsNeverOverwriteEachOther(unittest.TestCase):
|
||||
file every installer downloads, with a target table, exit 0."""
|
||||
|
||||
def _run(self, *flags: str, held: str) -> tuple:
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
target = Path(tmp, "retroarch.json")
|
||||
before = (ROOT / held).read_text(encoding="utf-8")
|
||||
target.write_text(before, encoding="utf-8")
|
||||
@@ -7327,7 +7325,7 @@ class PlatformSystemTypoGetsTheClosestNames(unittest.TestCase):
|
||||
from scripts.packs import platformpack
|
||||
|
||||
out = io.StringIO()
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp, \
|
||||
with tempfile.TemporaryDirectory() as tmp, \
|
||||
contextlib.redirect_stdout(out):
|
||||
result = platformpack.generate_pack(
|
||||
"retroarch", str(ROOT / "platforms"), {"files": {}, "indexes": {}},
|
||||
@@ -7362,7 +7360,7 @@ class HashInputNamesWhatItAccepts(unittest.TestCase):
|
||||
with self.subTest(raw=raw), self.assertRaises(ValueError) as ctx:
|
||||
parse_hash_input(raw)
|
||||
self.assertIn("SHA-256 (64)", str(ctx.exception))
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
listing = Path(tmp, "hashes.txt")
|
||||
listing.write_text("# list\n490f666e1afb15b7362b406ed1cea246 a.bin\nb.bin\n")
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
@@ -7465,7 +7463,7 @@ class ToolsRunFromAnyDirectory(unittest.TestCase):
|
||||
self.assertIn("sony-playstation", proc.stdout)
|
||||
|
||||
def test_a_typed_path_is_read_from_where_it_was_typed(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proc = self._run(
|
||||
Path(tmp), str(ROOT / "scripts" / "generate_pack.py"),
|
||||
"--manifest-targets", "--output-dir", "lists",
|
||||
@@ -7658,7 +7656,7 @@ class AnUnknownSystemIsRefusedBeforeAnyWork(unittest.TestCase):
|
||||
output lock and refreshed every data directory, then ended on a WARNING."""
|
||||
|
||||
def test_refused_before_the_lock_and_the_refresh(self):
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
out = Path(tmp) / "never"
|
||||
with mock.patch.dict(os.environ, {"RETROBIOS_OFFLINE": ""}):
|
||||
proc = subprocess.run(
|
||||
|
||||
@@ -46,7 +46,7 @@ _config_dir: Path | None = None
|
||||
|
||||
def setUpModule() -> None:
|
||||
global _config_dir
|
||||
_config_dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
_config_dir = Path(tempfile.mkdtemp())
|
||||
config = _config_dir / "gitconfig"
|
||||
config.write_text(
|
||||
"[user]\n\tname = Test\n\temail = test@example.invalid\n"
|
||||
@@ -97,7 +97,7 @@ class FakeHost(runner.Host):
|
||||
|
||||
class Scratch(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
|
||||
def context(self, jobs: dict, **kwargs) -> runner.Context:
|
||||
|
||||
@@ -172,8 +172,7 @@ class BatoceraExportRoundTrip(unittest.TestCase):
|
||||
|
||||
class VerifyAcceptsAnyListedMd5(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=scratch if scratch.is_dir() else None)
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.root = Path(self.tmp.name)
|
||||
|
||||
@@ -398,8 +397,7 @@ class SeveralAcceptedMd5BecomeAList(unittest.TestCase):
|
||||
exec(compile(produced, "batocera-systems", "exec"), namespace)
|
||||
item = namespace["systems"]["psx"]["biosFiles"][0]
|
||||
self.assertEqual(item["md5"], [C, SECOND])
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
with tempfile.TemporaryDirectory(dir=scratch if scratch.is_dir() else None) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
(Path(tmp) / "bios").mkdir()
|
||||
systems = {"psx": {"name": "PSX", "biosFiles": [item]}}
|
||||
for payload, missing in (
|
||||
|
||||
+5
-10
@@ -47,7 +47,6 @@ from model import measurements as mr
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
TMP = REPO_ROOT / "tmp" / "tests"
|
||||
|
||||
PROFILE = """\
|
||||
emulator: Fake
|
||||
@@ -391,8 +390,7 @@ def screen(base: int) -> str:
|
||||
|
||||
class Workspace(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
TMP.mkdir(parents=True, exist_ok=True)
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=TMP))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.root = self.tmp / "repo"
|
||||
(self.root / "emulators").mkdir(parents=True)
|
||||
subprocess.run(["git", "init", "-q", str(self.root)], check=True)
|
||||
@@ -556,7 +554,7 @@ class ChildEnvironment(unittest.TestCase):
|
||||
host = FakeHost()
|
||||
host.run = lambda argv, **kw: (seen.append(kw.get("env")),
|
||||
subprocess.CompletedProcess([], 0, '{"id": "x"}', ""))[1]
|
||||
with tempfile.TemporaryDirectory(dir=TMP) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
paths = probes_host.Paths(root=Path(tmp), home=Path(tmp) / "h", content=Path(tmp) / "c",
|
||||
db=Path(tmp) / "db.json", content_file=probes_host.CONTENT_FILE)
|
||||
c = probes_campaign.Campaign(paths, probes_host.Settings(echo=False), host, lock_path=Path(tmp) / "l")
|
||||
@@ -615,8 +613,7 @@ class BuildIsolation(unittest.TestCase):
|
||||
SUB = "https://example.invalid/team/sub.git"
|
||||
|
||||
def setUp(self) -> None:
|
||||
TMP.mkdir(parents=True, exist_ok=True)
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=TMP))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
self.pwned = self.tmp / "PWNED"
|
||||
sub = self.repo("sub", {"sub.c": "int x;\n"})
|
||||
@@ -722,8 +719,7 @@ class BuildIsolation(unittest.TestCase):
|
||||
|
||||
class BuiltCore(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
TMP.mkdir(parents=True, exist_ok=True)
|
||||
self.tree = Path(tempfile.mkdtemp(dir=TMP))
|
||||
self.tree = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tree, True)
|
||||
self.secret = self.tree.parent / f"{self.tree.name}-host-file"
|
||||
self.secret.write_text("host secret")
|
||||
@@ -1068,8 +1064,7 @@ class FakeCorePasses(Workspace):
|
||||
_prefix, isolation = core_probe.sandbox_argv([Path(tempfile.gettempdir())])
|
||||
if isolation != core_probe.SANDBOX:
|
||||
raise unittest.SkipTest(f"no sandbox here ({isolation}): install bubblewrap")
|
||||
TMP.mkdir(parents=True, exist_ok=True)
|
||||
cls.build = Path(tempfile.mkdtemp(dir=TMP))
|
||||
cls.build = Path(tempfile.mkdtemp())
|
||||
source = cls.build / "fake.c"
|
||||
source.write_text(FAKE_CORE, encoding="utf-8")
|
||||
# The core sees no variable of the host, so its behaviour is compiled in.
|
||||
|
||||
@@ -47,7 +47,7 @@ class ThePackReadmeNamesTheSpellingsItLeavesOut(unittest.TestCase):
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import emulator_profiles_cache
|
||||
import generate_db
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
|
||||
@@ -35,7 +35,7 @@ class APrimaryUnderAnotherCasing(unittest.TestCase):
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.files: dict = {}
|
||||
self.by_name: dict = {}
|
||||
|
||||
@@ -670,7 +670,7 @@ class RepositoryWiringTests(unittest.TestCase):
|
||||
import tempfile
|
||||
from pathlib import Path as _Path
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
targets = _Path(tmp) / "targets"
|
||||
targets.mkdir()
|
||||
(targets / "solo.yml").write_text(
|
||||
@@ -688,7 +688,7 @@ class RepositoryWiringTests(unittest.TestCase):
|
||||
scraped = sorted(cf._target_scrapers())
|
||||
self.assertTrue(scraped)
|
||||
platform = scraped[0]
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
targets = _Path(tmp) / "targets"
|
||||
targets.mkdir()
|
||||
(targets / f"{platform}.yml").write_text(
|
||||
|
||||
@@ -179,9 +179,7 @@ class OneFileThroughTheBrowser(unittest.TestCase):
|
||||
|
||||
from resolve import review
|
||||
|
||||
scratch = REPO_ROOT / "tmp" / "tests"
|
||||
scratch.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=scratch) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
(Path(directory) / "bios").mkdir()
|
||||
(Path(directory) / "bios" / "boot.rom").write_bytes(b"boot")
|
||||
from core.hashing import compute_hashes
|
||||
|
||||
@@ -35,8 +35,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
class ACoreFileFillsAFreeDeclaration(unittest.TestCase):
|
||||
def setUp(self):
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
bios = self.root / "bios" / "Maker" / "Console"
|
||||
bios.mkdir(parents=True)
|
||||
@@ -105,7 +104,7 @@ class AFileDeclaredUnderAnotherName(unittest.TestCase):
|
||||
|
||||
def test_the_report_lists_what_the_builder_packs(self):
|
||||
emulator_profiles_cache.clear()
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
bios = root / "bios" / "Apple" / "IIgs"
|
||||
bios.mkdir(parents=True)
|
||||
@@ -155,7 +154,7 @@ class AMissingDataDirectoryFailsTheRun(unittest.TestCase):
|
||||
from packs import datatrees
|
||||
from packs import platformpack
|
||||
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "platforms").mkdir()
|
||||
(root / "emulators").mkdir()
|
||||
@@ -197,7 +196,7 @@ class AFileNobodyHoldsIsAnOmission(unittest.TestCase):
|
||||
from packs.manifest import generate_manifest
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
for folder in ("platforms", "emulators", "bios"):
|
||||
(root / folder).mkdir()
|
||||
@@ -238,7 +237,7 @@ class AMemberNameIsNotALooseFile(unittest.TestCase):
|
||||
from packs import crossref
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "platforms").mkdir()
|
||||
(root / "emulators").mkdir()
|
||||
@@ -272,7 +271,7 @@ class TwoDeclarationsOfOnePath(unittest.TestCase):
|
||||
|
||||
def _run(self, first: str, second: str, spelling: str):
|
||||
emulator_profiles_cache.clear()
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
bios = root / "bios" / "Maker" / "Console"
|
||||
bios.mkdir(parents=True)
|
||||
@@ -323,7 +322,7 @@ class ANamelessWhitelistEntry(unittest.TestCase):
|
||||
|
||||
def test_the_pack_counts_what_verify_counts(self):
|
||||
emulator_profiles_cache.clear()
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
bios = root / "bios" / "Sony" / "PlayStation"
|
||||
bios.mkdir(parents=True)
|
||||
|
||||
@@ -160,7 +160,7 @@ class ParsingTests(unittest.TestCase):
|
||||
|
||||
def test_elf_comment(self) -> None:
|
||||
self.assertIsInstance(core_probe.elf_comment(Path(sys.executable).resolve()), list)
|
||||
with tempfile.NamedTemporaryFile(dir=REPO_ROOT / "tmp" / "tests") as handle:
|
||||
with tempfile.NamedTemporaryFile() as handle:
|
||||
handle.write(b"not an elf")
|
||||
handle.flush()
|
||||
self.assertEqual(core_probe.elf_comment(Path(handle.name)), [])
|
||||
@@ -178,7 +178,7 @@ class ParsingTests(unittest.TestCase):
|
||||
self.assertFalse(core_probe.uniform_frame(b"\x00\x00\x00\x00\x00\x00\x00\x01", 4))
|
||||
|
||||
def test_cue_tracks(self) -> None:
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cue = Path(tmp, "d.cue")
|
||||
cue.write_text('FILE "a b.bin" BINARY\n TRACK 01 MODE2/2352\nFILE c.bin BINARY\n',
|
||||
encoding="utf-8")
|
||||
@@ -477,7 +477,7 @@ class FakeCoreTests(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
cls.tmp = Path(tempfile.mkdtemp())
|
||||
source = cls.tmp / "fake.c"
|
||||
source.write_text(FAKE_CORE, encoding="utf-8")
|
||||
cls.core = cls.tmp / "fake_libretro.so"
|
||||
@@ -739,7 +739,7 @@ class Sandbox(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
if not core_probe.sandbox_argv([])[0]:
|
||||
self.skipTest("no working bwrap on this host")
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
self.out = self.tmp / "out"
|
||||
self.inputs = self.tmp / "inputs"
|
||||
|
||||
@@ -65,7 +65,7 @@ class _Collection(unittest.TestCase):
|
||||
payload = b""
|
||||
|
||||
def setUp(self):
|
||||
self._tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self._cwd = os.getcwd()
|
||||
os.chdir(self._tmp.name)
|
||||
for d in ("emulators", "platforms", "bios/Apple"):
|
||||
|
||||
@@ -24,7 +24,7 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class CoverageCache(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
self.work = Path(tempfile.mkdtemp())
|
||||
self.platforms = self.work / "platforms"
|
||||
self.platforms.mkdir()
|
||||
(self.platforms / "alpha.yml").write_text("platform: Alpha\n")
|
||||
|
||||
@@ -75,7 +75,7 @@ class GapReportSources(unittest.TestCase):
|
||||
self.assertIn("0 missing (need to be sourced)", text)
|
||||
|
||||
def test_a_directory_does_not_stand_for_a_file(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
(Path(tmp) / "bios" / "cpcemu" / "ROM").mkdir(parents=True)
|
||||
names = build_supplemental_index(str(Path(tmp) / "data"), str(Path(tmp) / "bios"))
|
||||
self.assertIsNone(entry_source({"name": "ROM"}, _index(data_names=names)))
|
||||
|
||||
@@ -36,7 +36,7 @@ class EachSourceIsParsedOnce(unittest.TestCase):
|
||||
import validate_schemas
|
||||
except ImportError as exc:
|
||||
self.skipTest(f"validate_schemas needs jsonschema: {exc}")
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
(root / "emulators").mkdir()
|
||||
(root / "platforms").mkdir()
|
||||
|
||||
+11
-13
@@ -32,7 +32,7 @@ class AliasesNeedAnUnambiguousName(unittest.TestCase):
|
||||
def _aliases(self, files: dict) -> dict:
|
||||
stub = types.ModuleType("scraper.coreinfo_scraper")
|
||||
stub.Scraper = _NoCoreInfo
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -91,7 +91,7 @@ class NoNetworkInTheBuild(unittest.TestCase):
|
||||
self.assertNotIn("urllib.request", source)
|
||||
|
||||
def test_hash_proven_entry_registers_its_own_name(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -109,7 +109,7 @@ class NoNetworkInTheBuild(unittest.TestCase):
|
||||
class AcceptedRevisionLists(unittest.TestCase):
|
||||
def test_a_list_of_sha1_names_every_held_revision(self):
|
||||
"""A profile accepting several revisions writes sha1 as a list."""
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -130,7 +130,7 @@ class AcceptedRevisionLists(unittest.TestCase):
|
||||
class CrossNamingStaysInItsProfile(unittest.TestCase):
|
||||
def test_an_alias_naming_a_sibling_entry_is_not_indexed(self):
|
||||
"""dosbox-x aliases MT32_CONTROL.ROM and CM32L_CONTROL.ROM to each other."""
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -160,9 +160,7 @@ class AnUnreadableSourceStopsTheRun(unittest.TestCase):
|
||||
|
||||
import generate_db
|
||||
|
||||
tmp_root = Path(__file__).resolve().parents[1] / "tmp"
|
||||
tmp_root.mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=tmp_root))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
@@ -181,7 +179,7 @@ class DrasticNamesTheDSDumps(unittest.TestCase):
|
||||
its own three names."""
|
||||
|
||||
def _aliases(self, files: dict) -> dict:
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -226,7 +224,7 @@ class AliasesFollowContentNotPrimaryCopy(unittest.TestCase):
|
||||
def _aliases(self, primary: str, copy: str) -> dict:
|
||||
files = {"s": {"name": primary, "path": f"bios/N64DD/{primary}", "md5": "m"}}
|
||||
copies = {"s": [{"name": copy, "path": f"bios/N64DD/{copy}"}]}
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -253,7 +251,7 @@ class AliasesFollowContentNotPrimaryCopy(unittest.TestCase):
|
||||
"b": {"name": "Satellaview_BS-X.sfc", "path": "bios/SNES/x.sfc", "md5": "m2"},
|
||||
}
|
||||
copies = {"b": [{"name": "BS-X.bin", "path": "bios/Satellaview/BS-X.bin"}]}
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -283,7 +281,7 @@ class TheSmsBiosKeepsItsNames(unittest.TestCase):
|
||||
"kiosk": {"name": "bios_U.sms", "path": "bios/Sega/MS/.variants/bios_U.sms.ee2c29ba",
|
||||
"md5": "mk"},
|
||||
}
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -303,7 +301,7 @@ class TheSmsBiosKeepsItsNames(unittest.TestCase):
|
||||
"v13": {"name": "SMS_us_1.3.sms", "path": "bios/Sega/MS/SMS_us_1.3.sms", "md5": "m13"},
|
||||
"other": {"name": "bios_U.sms", "path": "bios/Sega/MS/bios_U.sms", "md5": "mo"},
|
||||
}
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
@@ -319,7 +317,7 @@ class TheSmsBiosKeepsItsNames(unittest.TestCase):
|
||||
self.assertEqual(aliases, {})
|
||||
|
||||
def test_a_copy_under_its_machine_is_the_path_over_an_emulator_tree(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
bios = Path(tmp) / "bios"
|
||||
for rel in ("Other/zesarux/sms.rom", "Sega/Master System/SMS_us_1.3.sms"):
|
||||
(bios / rel).parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -26,7 +26,7 @@ class FlatDeclaredSet(unittest.TestCase):
|
||||
SYSTEM_ALIASES joined them."""
|
||||
import tempfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
platforms = Path(tmp)
|
||||
(platforms / "fx.yml").write_text(
|
||||
"platform: Fx\nverification_mode: existence\nsystems:\n"
|
||||
|
||||
@@ -36,7 +36,7 @@ def _wanted(data: bytes) -> dict:
|
||||
|
||||
class HeldDumpsAnswerCatalogEntries(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
|
||||
def test_combine_agrees_with_zlib(self):
|
||||
@@ -74,7 +74,7 @@ class ARomsetMemberIsASource(unittest.TestCase):
|
||||
def test_members_derive_and_concatenate(self):
|
||||
import zipfile
|
||||
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
chip, low, high = os.urandom(64), os.urandom(32), os.urandom(32)
|
||||
archive = root / "set.zip"
|
||||
@@ -111,7 +111,7 @@ class OneContentIsTransformedOnce(unittest.TestCase):
|
||||
def test_a_repeated_chip_is_transformed_once_and_keeps_its_first_path(self):
|
||||
import zipfile
|
||||
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
chip = os.urandom(64)
|
||||
files = {}
|
||||
|
||||
@@ -266,7 +266,7 @@ class ManifestInjectionIsAtomic(unittest.TestCase):
|
||||
|
||||
from scripts.packs import finalize
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[1] / "tmp") as d:
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
pack = Path(d) / "Pack.zip"
|
||||
with zipfile.ZipFile(pack, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
for i in range(20):
|
||||
|
||||
@@ -2098,7 +2098,7 @@ class LandingAChangeNamesTheCommitRules(unittest.TestCase):
|
||||
import tempfile
|
||||
|
||||
block = re.search(r"```bash\n(.*?)```", self._landing(), re.S).group(1)
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch:
|
||||
with tempfile.TemporaryDirectory() as scratch:
|
||||
clone = Path(scratch)
|
||||
(clone / ".git" / "hooks").mkdir(parents=True)
|
||||
(clone / "scripts").mkdir()
|
||||
|
||||
+9
-23
@@ -10,6 +10,7 @@ checksum of each layout and the staging location.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import scratch_dir
|
||||
|
||||
import contextlib
|
||||
import functools
|
||||
@@ -60,19 +61,6 @@ RELEASE_ASSETS = [
|
||||
]
|
||||
|
||||
|
||||
def _tempdir(test: unittest.TestCase) -> str:
|
||||
"""A scratch directory under the repository's tmp/, removed after the test.
|
||||
|
||||
The system temp directory is a RAM disk here, and directories left by
|
||||
every run piled up on it.
|
||||
"""
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
path = tempfile.mkdtemp(dir=str(scratch))
|
||||
test.addCleanup(shutil.rmtree, path, True)
|
||||
return path
|
||||
|
||||
|
||||
def _closed_port() -> int:
|
||||
"""A loopback port nothing listens on, so connecting is refused at once."""
|
||||
with socket.socket() as sock:
|
||||
@@ -252,7 +240,7 @@ class TestPackGrouping(unittest.TestCase):
|
||||
|
||||
class TestJoinVolumes(unittest.TestCase):
|
||||
def test_joined_volumes_reproduce_the_archive(self):
|
||||
tmp = Path(_tempdir(self))
|
||||
tmp = scratch_dir(self)
|
||||
archive = tmp / "pack.zip"
|
||||
with zipfile.ZipFile(archive, "w") as zf:
|
||||
zf.writestr("bios/scph5501.bin", b"\x01\x02" * 5000)
|
||||
@@ -301,7 +289,7 @@ class TestStagingIsolation(unittest.TestCase):
|
||||
"""Two downloads into one BIOS folder must not share a staging directory."""
|
||||
|
||||
def setUp(self):
|
||||
self.dest = Path(_tempdir(self))
|
||||
self.dest = scratch_dir(self)
|
||||
self.addCleanup(shutil.rmtree, self.dest, True)
|
||||
|
||||
def test_two_runs_stage_in_separate_directories(self):
|
||||
@@ -336,9 +324,7 @@ class ReleaseServer:
|
||||
volumes: int,
|
||||
zip_parts: bool = False,
|
||||
):
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=str(scratch)))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
(self.root / "assets").mkdir()
|
||||
archive = self.root / "assets" / pack_name
|
||||
with zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
@@ -434,10 +420,10 @@ class DownloaderCase(unittest.TestCase):
|
||||
self.pack_name, self.payload, self.volumes, self.zip_parts
|
||||
)
|
||||
self.addCleanup(self.server.close)
|
||||
self.dest = Path(_tempdir(self)) / "bios"
|
||||
self.dest = scratch_dir(self) / "bios"
|
||||
# A pack is gigabytes: staging it in the system temp directory fills
|
||||
# the RAM disk that /tmp is on the appliances these packs target.
|
||||
self.tmpdir = Path(_tempdir(self))
|
||||
self.tmpdir = scratch_dir(self)
|
||||
|
||||
def env(self) -> dict[str, str]:
|
||||
env = dict(os.environ)
|
||||
@@ -612,7 +598,7 @@ class TestDownloadShell(DownloaderCase):
|
||||
"""unzip -o unlinks a file and writes the new one under its final
|
||||
name: a run killed mid-file left a partial BIOS where a valid one
|
||||
was. Extraction now writes beside the folder and renames."""
|
||||
shim = Path(_tempdir(self))
|
||||
shim = scratch_dir(self)
|
||||
(shim / "unzip").write_text(
|
||||
"#!/bin/sh\n"
|
||||
'for target; do :; done\n'
|
||||
@@ -641,7 +627,7 @@ class TestDownloadShell(DownloaderCase):
|
||||
def test_two_runs_into_one_folder_both_finish(self):
|
||||
"""Both runs staged in `<dest>/.retrobios-download` and the second
|
||||
emptied it while the first was still writing its parts."""
|
||||
shim = Path(_tempdir(self))
|
||||
shim = scratch_dir(self)
|
||||
real = shutil.which("curl")
|
||||
(shim / "curl").write_text(
|
||||
"#!/bin/sh\n"
|
||||
@@ -753,7 +739,7 @@ class TheShellDownloaderSendsTheToken(unittest.TestCase):
|
||||
one succeeded. A curl stand-in records what each call carries."""
|
||||
|
||||
def _calls(self, **env: str) -> str:
|
||||
scratch = Path(_tempdir(self))
|
||||
scratch = scratch_dir(self)
|
||||
log = scratch / "calls.log"
|
||||
fake = scratch / "curl"
|
||||
fake.write_text(
|
||||
|
||||
+2
-6
@@ -6823,9 +6823,7 @@ class OneOfASearchList(unittest.TestCase):
|
||||
from model.profiles import emulator_profiles_cache
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
repo = Path(__file__).resolve().parent.parent
|
||||
(repo / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=repo / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(self.root)
|
||||
@@ -7090,9 +7088,7 @@ class AnArchiveIsAMemberOfASet(unittest.TestCase):
|
||||
from model.profiles import emulator_profiles_cache
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
repo = Path(__file__).resolve().parent.parent
|
||||
(repo / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=repo / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
@@ -40,11 +40,8 @@ class PackAndReportAgree(unittest.TestCase):
|
||||
def test_each_emulator_pack_counts_as_verify_does(self):
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("database.json is not built")
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
for emulator in CASES:
|
||||
with self.subTest(emulator=emulator), tempfile.TemporaryDirectory(
|
||||
dir=REPO_ROOT / "tmp"
|
||||
) as out:
|
||||
with self.subTest(emulator=emulator), tempfile.TemporaryDirectory() as out:
|
||||
pack = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--emulator", emulator,
|
||||
"--offline", "--output-dir", out],
|
||||
@@ -85,8 +82,7 @@ class APlaceholderIsAnsweredByEvidence(unittest.TestCase):
|
||||
from packs.emulatorcheck import verify_emulator
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
@@ -930,7 +930,7 @@ class AStaleTruthIsRefused(unittest.TestCase):
|
||||
from exporter.native import load_inputs, StaleTruth
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
truth_dir = Path(tempfile.mkdtemp(dir=root / "tmp"))
|
||||
truth_dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, truth_dir, True)
|
||||
(truth_dir / "retropie.yml").write_text("platform: retropie\nsystems: {}\n")
|
||||
with self.assertRaises(StaleTruth):
|
||||
|
||||
@@ -77,7 +77,7 @@ class TheTruthDiffReadsTheSameLayer(unittest.TestCase):
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=str(REPO_ROOT / "tmp")) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
(root / "demo.yml").write_text(
|
||||
"platform: Demo\nsystems:\n"
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -617,7 +617,7 @@ class ExporterRegistry(unittest.TestCase):
|
||||
|
||||
import export_native
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
platforms = Path(directory)
|
||||
(platforms / "_registry.yml").write_text(
|
||||
"platforms:\n cardonly:\n native_list: none\n unwritten: {}\n",
|
||||
@@ -690,7 +690,7 @@ class ExporterRegistry(unittest.TestCase):
|
||||
def test_an_export_without_its_original_writes_nothing(self):
|
||||
from exporter.native import export_platform
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
output = Path(tmp) / "out"
|
||||
ok, messages = export_platform(
|
||||
"retroarch", discover_exporters()["retroarch"],
|
||||
@@ -1583,7 +1583,7 @@ class AnExportIsWrittenAsItsBytes(unittest.TestCase):
|
||||
|
||||
from exporter.native import _write_produced
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
_write_produced(root, {
|
||||
"FirmwareDatabase.cs": "a\r\nb\r\n",
|
||||
@@ -1612,7 +1612,7 @@ class AnExportWithoutTruthIsRefused(unittest.TestCase):
|
||||
from exporter.native import export_platform
|
||||
|
||||
exporter = discover_exporters()["batocera"]
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
output = Path(tmp) / "out"
|
||||
published = output / "batocera" / "batocera-systems"
|
||||
published.parent.mkdir(parents=True)
|
||||
@@ -1643,7 +1643,7 @@ class AnInvalidExportIsNotWritten(unittest.TestCase):
|
||||
self.skipTest("upstream cache not populated")
|
||||
exporter = discover_exporters()["romm"]
|
||||
config = native_layer(load_platform_config("romm", str(REPO_ROOT / "platforms")))
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
output = Path(tmp) / "out"
|
||||
published = output / "romm" / "known_bios_files.json"
|
||||
published.parent.mkdir(parents=True)
|
||||
@@ -2020,7 +2020,7 @@ class MisterDatabaseComesBackAsWritten(unittest.TestCase):
|
||||
def test_bytes_are_written_untouched(self):
|
||||
from exporter.native import _write_produced
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
_write_produced(Path(tmp), {"a.zip": b"PK\x03\x04\xff"}, {})
|
||||
self.assertEqual((Path(tmp) / "a.zip").read_bytes(), b"PK\x03\x04\xff")
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class FinalizeByExactName(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
with zipfile.ZipFile(Path(tmp) / "MiSTer_FPGA_Custom_BIOS_Pack.zip", "w") as zf:
|
||||
zf.writestr("README.txt", "custom")
|
||||
ok = verify_and_finalize_packs(tmp, {"files": {}, "indexes": {}})
|
||||
@@ -42,7 +42,7 @@ class APackFromAnotherRunIsLeftAlone(unittest.TestCase):
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
def build(platform: str) -> str:
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--platform", platform,
|
||||
|
||||
@@ -25,8 +25,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class ForeignTreeNames(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
# The collection's paths are relative to the repository root.
|
||||
self.addCleanup(os.chdir, os.getcwd())
|
||||
|
||||
@@ -29,8 +29,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class FrontendDigestDecides(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
root = Path(self.tmp.name)
|
||||
self.bios = root / "bios"
|
||||
|
||||
@@ -15,8 +15,6 @@ from model.region import REGIONS
|
||||
from scripts.scraper import game_dat_importer as importer
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
FIXTURES = ROOT / "tests" / "fixtures" / "game_dats"
|
||||
|
||||
try:
|
||||
@@ -56,7 +54,7 @@ class RegionTags(unittest.TestCase):
|
||||
|
||||
class FixtureImport(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.out = Path(self.temp.name)
|
||||
|
||||
def tearDown(self) -> None:
|
||||
@@ -193,7 +191,7 @@ class CommittedCatalogs(unittest.TestCase):
|
||||
self.assertEqual(importer.dump_catalog(doc), path.read_text())
|
||||
|
||||
def test_fixture_output_matches_the_schema(self) -> None:
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
out = Path(directory)
|
||||
for source in ("no-intro", "redump"):
|
||||
self.assertEqual(run_import(source, out).returncode, 0)
|
||||
|
||||
@@ -20,8 +20,6 @@ import generate_games_index as gi
|
||||
from model.romfolders import SystemResolver, load_setups
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
SETUP = """\
|
||||
setup: fixture
|
||||
@@ -72,7 +70,7 @@ ARCADE = {"profile": "mame", "bios": {"neogeo": ["mslug"]}}
|
||||
|
||||
class GamesIndexFixture(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
(self.tmp / "romfolders").mkdir()
|
||||
(self.tmp / "romfolders" / "fixture.yml").write_text(SETUP, encoding="utf-8")
|
||||
(self.tmp / "install").mkdir()
|
||||
|
||||
@@ -11,6 +11,7 @@ the pad reaching the console, a compositor covering it) is not exercised.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import scratch_dir
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
@@ -24,7 +25,6 @@ import signal
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import termios
|
||||
import time
|
||||
import unittest
|
||||
@@ -74,14 +74,6 @@ INTERFACE_KEYS = {
|
||||
GPTOKEYB_NAMES = set(SEQUENCES) | {"backspace", '\\"'}
|
||||
|
||||
|
||||
def _tempdir(test: unittest.TestCase) -> Path:
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
path = Path(tempfile.mkdtemp(dir=str(scratch)))
|
||||
test.addCleanup(shutil.rmtree, path, True)
|
||||
return path
|
||||
|
||||
|
||||
def read_gptk(path: Path) -> dict[str, list[str]]:
|
||||
"""key -> values, as gptokeyb's parseConfigFile reads `key = value`."""
|
||||
mapping: dict[str, list[str]] = {}
|
||||
@@ -282,7 +274,7 @@ class TheArchives(unittest.TestCase):
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
self.out = _tempdir(self)
|
||||
self.out = scratch_dir(self)
|
||||
|
||||
def test_every_release_archive_is_built(self):
|
||||
self.assertEqual(set(port.ARCHIVES), set(self.LAYOUT))
|
||||
@@ -364,7 +356,7 @@ class TheArchives(unittest.TestCase):
|
||||
self.assertEqual(zf.read(f"{folder}/packs.txt").decode(), expected)
|
||||
|
||||
def test_an_unpinned_installer_is_refused(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
for name in ("install.py", "install.sh", "LICENSE", "NOTICE"):
|
||||
shutil.copy(REPO_ROOT / name, root / name)
|
||||
shutil.copytree(PORTS, root / "ports")
|
||||
@@ -694,7 +686,7 @@ class Device:
|
||||
|
||||
def __init__(self, test: unittest.TestCase, **env: str):
|
||||
self.test = test
|
||||
self.root = _tempdir(test)
|
||||
self.root = scratch_dir(test)
|
||||
self.state = self.root / "state"
|
||||
self.state.mkdir()
|
||||
# Registered before every other cleanup, so it runs after them.
|
||||
@@ -1568,7 +1560,9 @@ class TheBatoceraPort(unittest.TestCase):
|
||||
socket_dir.mkdir()
|
||||
import socket as _socket
|
||||
sock = _socket.socket(_socket.AF_UNIX)
|
||||
sock.bind(str(socket_dir / "X0"))
|
||||
# A socket address holds 108 bytes, fewer than a scratch folder can.
|
||||
with contextlib.chdir(socket_dir):
|
||||
sock.bind("X0")
|
||||
self.addCleanup(sock.close)
|
||||
cookie = device.root / "Xauthority"
|
||||
cookie.write_text("")
|
||||
|
||||
@@ -841,7 +841,7 @@ class WritersPutTheValuesOnDisk(unittest.TestCase):
|
||||
fixtures use the layout the profiles use (entries indented two)."""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(dir=Path(__file__).resolve().parents[1] / "tmp"))
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(self.dir, True))
|
||||
|
||||
def test_fbneo_writes_a_changed_crc32(self):
|
||||
|
||||
@@ -24,7 +24,7 @@ class HashesAreReadOncePerContent(unittest.TestCase):
|
||||
per platform and entry, in one process."""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.file = self.dir / "rom.bin"
|
||||
self.file.write_bytes(b"a" * 64)
|
||||
@@ -52,7 +52,7 @@ class OneDigestLoopForFilesAndStreams(unittest.TestCase):
|
||||
DATA = bytes(range(256)) * 600 # over two 64 KiB reads
|
||||
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.file = self.dir / "rom.bin"
|
||||
self.file.write_bytes(self.DATA)
|
||||
|
||||
+179
-209
File diff suppressed because it is too large.
Load diff
+11
-18
@@ -9,6 +9,7 @@ menu) is not exercised.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import scratch_dir
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
@@ -17,7 +18,6 @@ import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
@@ -110,16 +110,9 @@ class AppRepository(FakeRepository):
|
||||
timeout=120, check=False, stdin=subprocess.DEVNULL)
|
||||
|
||||
|
||||
def _tempdir(test: unittest.TestCase) -> Path:
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
path = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
test.addCleanup(shutil.rmtree, path, True)
|
||||
return path
|
||||
|
||||
|
||||
class Placement(unittest.TestCase):
|
||||
def test_each_card_and_where_its_app_goes(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
expected = {"muOS": "ARCHIVE", "KNULLI": "roms/ports", "ROCKNIX": ".config/modules"}
|
||||
for system, folder in expected.items():
|
||||
with self.subTest(system=system):
|
||||
@@ -131,7 +124,7 @@ class Placement(unittest.TestCase):
|
||||
self.assertEqual(card.why, "")
|
||||
|
||||
def test_a_bios_folder_inside_the_card_finds_its_root(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
bios = make_card(root / "sd1", "muOS")
|
||||
bios.mkdir(parents=True, exist_ok=True)
|
||||
self.assertEqual(install.card_app(bios).root, root / "sd1")
|
||||
@@ -139,7 +132,7 @@ class Placement(unittest.TestCase):
|
||||
self.assertIsNone(install.card_app(root / "sd1"))
|
||||
|
||||
def test_cards_without_a_launcher_say_why(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
for system, words in (("Onion", "has no Python"), ("MinUI", "has no Python"),
|
||||
("spruceOS", "no RetroBIOS app for spruceOS")):
|
||||
with self.subTest(system=system):
|
||||
@@ -148,7 +141,7 @@ class Placement(unittest.TestCase):
|
||||
self.assertIn(words, card.why)
|
||||
|
||||
def test_a_folder_on_no_card(self):
|
||||
self.assertIsNone(install.card_app(_tempdir(self) / "bios"))
|
||||
self.assertIsNone(install.card_app(scratch_dir(self) / "bios"))
|
||||
|
||||
def test_the_table_names_systems_detection_names(self):
|
||||
names = {rule.name for rule in install._card_rules()}
|
||||
@@ -215,7 +208,7 @@ class TheList(unittest.TestCase):
|
||||
for entry in launcher["members"]]
|
||||
data = install.app_archive(members)
|
||||
from installer_build import port
|
||||
built = _tempdir(self) / port.MUOS_APP
|
||||
built = scratch_dir(self) / port.MUOS_APP
|
||||
port.build_archive(port.MUOS_APP, built)
|
||||
with zipfile.ZipFile(built) as release, zipfile.ZipFile(io.BytesIO(data)) as ours:
|
||||
self.assertEqual(release.namelist(), ours.namelist())
|
||||
@@ -332,7 +325,7 @@ class TheQuestion(unittest.TestCase):
|
||||
"""Line mode at a terminal asks once, and only yes puts the app."""
|
||||
|
||||
def run_finish(self, answer: str, system: str = "muOS", **given) -> list:
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
bios = make_card(root / "card", system)
|
||||
args = mock.Mock(add_app=False, yes=False)
|
||||
for key, value in given.items():
|
||||
@@ -385,7 +378,7 @@ class TheOption(unittest.TestCase):
|
||||
cls.repo.__exit__(None, None, None)
|
||||
|
||||
def test_refused_where_it_cannot_apply(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
pack = root / "RetroArch_BIOS_Pack.zip"
|
||||
zipfile.ZipFile(pack, "w").close()
|
||||
for options, words in (
|
||||
@@ -405,7 +398,7 @@ class TheOption(unittest.TestCase):
|
||||
self.assertIn(words, proc.stderr)
|
||||
|
||||
def test_refused_for_a_folder_on_no_card_or_no_launcher(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
for system, words in ((None, "is not on a card this installer recognises"),
|
||||
("Onion", "Onion has no Python"),
|
||||
("spruceOS", "no RetroBIOS app for spruceOS yet")):
|
||||
@@ -424,7 +417,7 @@ class TheOption(unittest.TestCase):
|
||||
self.assertFalse([e for e in events if e["event"] == "download"])
|
||||
|
||||
def test_applied_after_the_install_and_reported(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
for system in ("muOS", "KNULLI"):
|
||||
with self.subTest(system=system):
|
||||
bios = make_card(root / system, system)
|
||||
@@ -449,7 +442,7 @@ class TheOption(unittest.TestCase):
|
||||
self.assertEqual((again.returncode, app["ok"], app["written"]), (0, True, []))
|
||||
|
||||
def test_not_added_when_the_install_does_not_finish(self):
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
make_card(root / "card", "muOS")
|
||||
# A BIOS folder that is a file: every download fails.
|
||||
(root / "card" / "MUOS" / "bios").rmdir()
|
||||
|
||||
@@ -30,7 +30,7 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class CoreDirectories(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(self.tmp, ignore_errors=True))
|
||||
|
||||
def test_the_config_detection_read_names_the_cores(self):
|
||||
@@ -193,7 +193,7 @@ class ACoreTheListDoesNotKnow(unittest.TestCase):
|
||||
"""A core newer than the list (parallel_dc, issue 87) loses nothing its .info declares."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
|
||||
def test_only_names_no_profile_answers_for(self):
|
||||
@@ -456,7 +456,7 @@ class APlatformFileSettledByCoresAndSystems(unittest.TestCase):
|
||||
the event and a --declared-only check give the same answer."""
|
||||
import hashlib
|
||||
|
||||
tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, tmp, True)
|
||||
payloads = {letter: letter.encode() * 3 for letter in "abc"}
|
||||
manifest = self.manifest()
|
||||
@@ -516,7 +516,7 @@ class APlatformFileSettledByCoresAndSystems(unittest.TestCase):
|
||||
|
||||
class RefusedBeforeAnyInstall(unittest.TestCase):
|
||||
def test_a_platform_shipping_its_cores_stops_the_run_first(self):
|
||||
tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, tmp, True)
|
||||
detected = [("retroarch", tmp / "system"), ("batocera", tmp / "bios")]
|
||||
(tmp / "retroarch.cfg").write_text("")
|
||||
@@ -551,7 +551,7 @@ class AnUnknownTargetStopsTheRunFirst(unittest.TestCase):
|
||||
the run ended without a summary."""
|
||||
|
||||
def test_nothing_is_fetched_when_one_platform_lacks_the_target(self):
|
||||
tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, tmp, True)
|
||||
detected = [("emudeck", tmp / "bios"), ("retroarch", tmp / "system")]
|
||||
lists = {"emudeck": {"steamos": {"cores": []}}, "retroarch": {"x86_64": {"cores": []}}}
|
||||
|
||||
@@ -514,7 +514,7 @@ class AStoppedRunCountsWhatLanded(unittest.TestCase):
|
||||
self.addCleanup(httpd.server_close)
|
||||
self.addCleanup(httpd.shutdown)
|
||||
self.addCleanup(_HeldHandler.release.set)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
dest = Path(tmp) / "bios"
|
||||
env = dict(os.environ,
|
||||
RETROBIOS_BASE_URL=f"http://127.0.0.1:{httpd.server_address[1]}")
|
||||
@@ -760,7 +760,7 @@ class ASettingsFileThisUserCannotRead(unittest.TestCase):
|
||||
word on the file, where the same refusal on retroarch.cfg is said."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
install._DETECTION_REFUSED.clear()
|
||||
self.addCleanup(install._DETECTION_REFUSED.clear)
|
||||
@@ -789,7 +789,7 @@ class AConfigThatFailsToRead(unittest.TestCase):
|
||||
refusal was said. Absence itself stays silent."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
install._DETECTION_REFUSED.clear()
|
||||
self.addCleanup(install._DETECTION_REFUSED.clear)
|
||||
@@ -860,7 +860,7 @@ class ARefusalTheProbeDoesNotRaise(unittest.TestCase):
|
||||
@unittest.skipIf(os.name == "nt" or os.geteuid() == 0,
|
||||
"a folder without search permission is POSIX")
|
||||
def test_a_quiet_false_is_still_told_from_absence(self):
|
||||
base = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
base = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, base, True)
|
||||
closed = base / "closed"
|
||||
closed.mkdir()
|
||||
@@ -940,7 +940,7 @@ class RetroDeckBiosFolderNamedAsDest(unittest.TestCase):
|
||||
BIOS folder, put every file under bios/bios, which RetroDECK never reads."""
|
||||
|
||||
def test_the_files_go_below_the_retrodeck_folder(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "bios").mkdir()
|
||||
choice = install.card_choice("retrodeck", "retrodeck", root / "bios")
|
||||
@@ -949,7 +949,7 @@ class RetroDeckBiosFolderNamedAsDest(unittest.TestCase):
|
||||
self.assertFalse(choice.refused)
|
||||
|
||||
def test_the_retrodeck_folder_itself_is_kept(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "bios").mkdir()
|
||||
choice = install.card_choice("retrodeck", "retrodeck", root)
|
||||
@@ -1042,7 +1042,7 @@ class OutputToAFileAsksNothing(unittest.TestCase):
|
||||
with open(read, "rb") as reader, open(write, "w") as writer:
|
||||
self.assertEqual(install._output_kind(writer), "pipe")
|
||||
del reader
|
||||
with tempfile.TemporaryFile("w", dir=REPO_ROOT / "tmp") as handle:
|
||||
with tempfile.TemporaryFile("w") as handle:
|
||||
self.assertEqual(install._output_kind(handle), "file")
|
||||
|
||||
|
||||
@@ -1128,7 +1128,7 @@ class SmallWordings(unittest.TestCase):
|
||||
self.assertNotIn("Install for:", out.getvalue())
|
||||
|
||||
def test_nothing_detected_is_said(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as home:
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
env = dict(os.environ, HOME=home, USERPROFILE=home, XDG_CONFIG_HOME=home,
|
||||
RETROBIOS_OS="linux")
|
||||
proc = subprocess.run(
|
||||
@@ -1203,7 +1203,7 @@ class AClosedFolderBehindALink(unittest.TestCase):
|
||||
that loops was named by its open parent."""
|
||||
|
||||
def setUp(self):
|
||||
self.base = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.base = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.base, True)
|
||||
self.home = self.base / "home"
|
||||
self.home.mkdir()
|
||||
@@ -1243,7 +1243,7 @@ class TheQuietConfigReadSaysNothing(unittest.TestCase):
|
||||
the human output never showed."""
|
||||
|
||||
def test_no_event_and_no_line(self):
|
||||
base = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
base = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, base, True)
|
||||
closed = base / "home" / ".config" / "EmuDeck"
|
||||
closed.mkdir(parents=True)
|
||||
@@ -1320,7 +1320,7 @@ class NotFoundWithAClosedFolder(unittest.TestCase):
|
||||
if e["event"] == "error"], [("detect", "not_found")])
|
||||
|
||||
def test_the_manual_prompt_says_why_there_is_no_default(self):
|
||||
home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, home, True)
|
||||
asked = []
|
||||
install._DETECTION_REFUSED[:] = [(home / ".config" / "EmuDeck", "Permission denied")]
|
||||
|
||||
@@ -92,7 +92,7 @@ class RealListParity(unittest.TestCase):
|
||||
contextlib.redirect_stderr(io.StringIO()):
|
||||
platformpack.generate_pack(
|
||||
plat, str(REPO_ROOT / "platforms"), self.db, str(REPO_ROOT / "bios"),
|
||||
str(REPO_ROOT / "tmp"), emulators_dir=str(REPO_ROOT / "emulators"),
|
||||
tempfile.gettempdir(), emulators_dir=str(REPO_ROOT / "emulators"),
|
||||
zip_contents=self.zip_contents, emu_profiles=self.profiles,
|
||||
offline=True, record=record, **options)
|
||||
prefix = f"{base}/" if base else ""
|
||||
@@ -191,7 +191,7 @@ class RealListParity(unittest.TestCase):
|
||||
contextlib.redirect_stderr(io.StringIO()):
|
||||
emulatorpack.generate_emulator_pack(
|
||||
[profile], str(REPO_ROOT / "emulators"), self.db,
|
||||
str(REPO_ROOT / "bios"), str(REPO_ROOT / "tmp"),
|
||||
str(REPO_ROOT / "bios"), tempfile.gettempdir(),
|
||||
standalone=True, zip_contents=self.zip_contents,
|
||||
offline=True, record=record)
|
||||
files, omitted = install._narrow_to_emulators(
|
||||
@@ -337,7 +337,7 @@ class Lists(unittest.TestCase):
|
||||
"""A list written for the runs below, in tmp/."""
|
||||
|
||||
def setUp(self):
|
||||
scratch = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
scratch = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(scratch.cleanup)
|
||||
self.root = Path(scratch.name)
|
||||
self.dest = self.root / "bios"
|
||||
@@ -596,7 +596,7 @@ class ExpertRuns(Lists):
|
||||
except ImportError as exc:
|
||||
self.skipTest(f"validate_schemas needs jsonschema: {exc}")
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as root:
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
(Path(root) / "install" / "standalone").mkdir(parents=True)
|
||||
(Path(root) / "install" / "retroarch.json").write_text(
|
||||
json.dumps({**LIST, "truth_files": None}), encoding="utf-8")
|
||||
|
||||
@@ -72,7 +72,7 @@ class NamesAFatCardCannotHold(unittest.TestCase):
|
||||
card each write failed with EINVAL, on every run."""
|
||||
|
||||
def test_the_probe_reads_einval_as_a_refusal(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
refused = OSError(errno.EINVAL, "Invalid argument")
|
||||
closed = PermissionError(errno.EACCES, "Permission denied")
|
||||
with mock.patch.object(install.os, "name", "posix"):
|
||||
@@ -88,7 +88,7 @@ class NamesAFatCardCannotHold(unittest.TestCase):
|
||||
self.assertFalse(install.holds_fat_refused_names(Path(".")))
|
||||
|
||||
def _install(self, holds: bool) -> tuple[str, list[str]]:
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
old, dest = root / "old", root / "dest"
|
||||
old.mkdir()
|
||||
|
||||
@@ -35,8 +35,6 @@ import install
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
TMP_ROOT = REPO_ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def _crc(data: bytes) -> str:
|
||||
@@ -299,7 +297,7 @@ class Card:
|
||||
a saved file list."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.root = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.bios = self.root / "card" / "BIOS"
|
||||
self.roms = self.root / "card" / "Roms"
|
||||
self.bios.mkdir(parents=True)
|
||||
@@ -398,7 +396,7 @@ class Identification(GamesTestCase):
|
||||
self.assertEqual(plan.not_games, 1)
|
||||
|
||||
def test_a_folder_of_whole_names_holds_only_those_files(self):
|
||||
root = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
for name in ("C3.EXE", "c3.eng", "readme.txt"):
|
||||
(root / name).write_bytes(b"x")
|
||||
@@ -1079,7 +1077,7 @@ class Published(unittest.TestCase):
|
||||
def test_a_card_reads_with_the_published_index(self):
|
||||
if not (REPO_ROOT / "install" / "games" / "index.json").exists():
|
||||
self.skipTest("install/games/ not generated")
|
||||
root = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
bios = root / "userdata" / "bios"
|
||||
bios.mkdir(parents=True)
|
||||
|
||||
@@ -131,6 +131,9 @@ class Repository:
|
||||
muOS setup, and every payload."""
|
||||
|
||||
def __init__(self, test: unittest.TestCase) -> None:
|
||||
# The screens print the card's path and the word budgets count it:
|
||||
# the per-module scratch folder of run_tests.py is long enough to
|
||||
# wrap it onto more lines.
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
test.addCleanup(shutil.rmtree, self.root, True)
|
||||
|
||||
@@ -93,9 +93,7 @@ def _offline_env() -> dict:
|
||||
|
||||
class Scratch(unittest.TestCase):
|
||||
def setUp(self):
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=scratch))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.dest = self.root / "system"
|
||||
self.list = self.root / "retroarch.json"
|
||||
|
||||
@@ -81,9 +81,7 @@ class Repository(unittest.TestCase):
|
||||
tree = TREE
|
||||
|
||||
def setUp(self):
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=scratch))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.served = self.root / "served"
|
||||
(self.served / "install").mkdir(parents=True)
|
||||
@@ -462,9 +460,7 @@ class TheSwapIsWhole(unittest.TestCase):
|
||||
failure puts the earlier set back, a cleanup that fails keeps the pack."""
|
||||
|
||||
def setUp(self):
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=scratch))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.out = self.root / "out"
|
||||
self.out.mkdir()
|
||||
|
||||
@@ -356,7 +356,7 @@ class ACraftedRecord(unittest.TestCase):
|
||||
the BIOS folder, through a link, or anything but a regular file."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.folder = self.root / "bios"
|
||||
self.folder.mkdir()
|
||||
@@ -418,7 +418,7 @@ class AFoldingDrive(unittest.TestCase):
|
||||
another setup are compared folded there."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.folder = self.root / "bios"
|
||||
self.folder.mkdir()
|
||||
@@ -472,7 +472,7 @@ class ReviewOfTheRemoval(unittest.TestCase):
|
||||
"""What a review of the first version found, each held by a test."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.folder = self.root / "bios"
|
||||
self.folder.mkdir()
|
||||
@@ -747,7 +747,7 @@ class MisplacedCopies(unittest.TestCase):
|
||||
self.assertIn(words, proc.stderr)
|
||||
|
||||
def test_a_place_a_list_reads_or_a_setup_names_stays(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
folder = root / "bios"
|
||||
folder.mkdir()
|
||||
@@ -787,7 +787,7 @@ class MisplacedCopies(unittest.TestCase):
|
||||
def test_a_card_whose_folder_is_the_roms_root_keeps_its_games(self):
|
||||
"""EmuELEC installs into /storage/roms: ports/doom/doom2.wad is the
|
||||
user's game, bios/old/doom2.wad a copy in the wrong place."""
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
folder = root / "roms"
|
||||
wad = b"doom ii"
|
||||
|
||||
@@ -540,7 +540,7 @@ class FakeRepository:
|
||||
self.selection = selection
|
||||
|
||||
def __enter__(self) -> FakeRepository:
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
(self.root / "install").mkdir()
|
||||
(self.root / "bios").mkdir()
|
||||
files = []
|
||||
@@ -889,7 +889,7 @@ class InstallMatchesASystemPack(unittest.TestCase):
|
||||
def _packed(self, systems, regions) -> set[str]:
|
||||
import zipfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out:
|
||||
with tempfile.TemporaryDirectory() as out:
|
||||
zip_path = platformpack.generate_pack(
|
||||
self.PLATFORM, str(REPO_ROOT / "platforms"), self.db,
|
||||
str(REPO_ROOT / "bios"), out,
|
||||
@@ -929,7 +929,7 @@ class DataTreesFollowTheSystemsTheyServe(InstallMatchesASystemPack):
|
||||
from model.registry import load_data_dir_registry
|
||||
|
||||
# The trees come from the registry the manifest reads by itself.
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out:
|
||||
with tempfile.TemporaryDirectory() as out:
|
||||
zip_path = platformpack.generate_pack(
|
||||
self.PLATFORM, str(REPO_ROOT / "platforms"), self.db,
|
||||
str(REPO_ROOT / "bios"), out,
|
||||
@@ -1056,7 +1056,7 @@ class AHeldFileTheInstallerCannotFetch(unittest.TestCase):
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import emulator_profiles_cache
|
||||
import generate_db
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
@@ -1137,7 +1137,7 @@ class AStandaloneLayoutBelowTheBiosFolder(unittest.TestCase):
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import emulator_profiles_cache
|
||||
import generate_db
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
@@ -1220,7 +1220,7 @@ class AnExtraBesideItsDeclarationBelowTheBiosFolder(unittest.TestCase):
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import emulator_profiles_cache
|
||||
import generate_db
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
@@ -1434,7 +1434,7 @@ class ANativeNameSelectsOneSetEverywhere(unittest.TestCase):
|
||||
import io
|
||||
import zipfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out, \
|
||||
with tempfile.TemporaryDirectory() as out, \
|
||||
contextlib.redirect_stdout(io.StringIO()):
|
||||
zip_path = platformpack.generate_pack(
|
||||
platform, str(REPO_ROOT / "platforms"), self.db,
|
||||
|
||||
+48
-55
@@ -720,7 +720,7 @@ class Flow(unittest.TestCase):
|
||||
self.assertIsNone(install.typed_path('""'))
|
||||
|
||||
def test_the_browser_lists_folders_and_goes_up(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
for name in ("system", ".config", "Bios"):
|
||||
(root / name).mkdir()
|
||||
@@ -748,7 +748,7 @@ class Flow(unittest.TestCase):
|
||||
"""With no usual folder the browser opens at HOME, on Use this
|
||||
folder: A five times installed the BIOS files into ~. At HOME or a
|
||||
drive's root, A goes into the first folder instead."""
|
||||
home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, home, True)
|
||||
(home / "Games").mkdir()
|
||||
state = install.TuiState(os_type="linux", home=home)
|
||||
@@ -765,7 +765,7 @@ class Flow(unittest.TestCase):
|
||||
self.assertNotEqual(state.browse_rows[state.focus["browse"]].action, "use")
|
||||
|
||||
def test_cards_are_listed_first(self):
|
||||
card = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
card = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, card, True)
|
||||
(card / ".system").mkdir()
|
||||
(card / ".system" / "version.txt").write_text("NextUI-20250101\n")
|
||||
@@ -775,7 +775,7 @@ class Flow(unittest.TestCase):
|
||||
self.assertEqual(rows[2].label, f"{card} (NextUI card)")
|
||||
|
||||
def test_a_mounted_card_is_a_setup_of_its_own(self):
|
||||
card = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
card = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, card, True)
|
||||
(card / ".system").mkdir()
|
||||
(card / ".system" / "version.txt").write_text("MinUI-20250101\n")
|
||||
@@ -1856,7 +1856,7 @@ class ControlCharacters(unittest.TestCase):
|
||||
self.assertIn("?[2Jevil.bin", "\n".join(lines))
|
||||
|
||||
def test_a_folder_name_in_the_browser(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "x\x1b]52;c;x\x07").mkdir()
|
||||
state = fresh_state()
|
||||
@@ -2092,7 +2092,7 @@ class CleanupSurvivesABrokenTerminal(unittest.TestCase):
|
||||
CleanupSurvivesABrokenTerminal.Tty.broken = True
|
||||
|
||||
self.addCleanup(setattr, CleanupSurvivesABrokenTerminal.Tty, "broken", False)
|
||||
work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
work = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, work, True)
|
||||
with mock.patch.object(install._TuiTerminal, "draw", breaking_draw), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
@@ -2283,7 +2283,7 @@ class TicksBarAndPaths(unittest.TestCase):
|
||||
" 50 files failed, all for one reason: folder not writable."])
|
||||
|
||||
def test_folder_inside_a_card_offers_its_root(self):
|
||||
card = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
card = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, card, True)
|
||||
(card / ".system").mkdir()
|
||||
(card / ".system" / "version.txt").write_text("MinUI-20250101\n")
|
||||
@@ -2329,7 +2329,7 @@ class TicksBarAndPaths(unittest.TestCase):
|
||||
self.assertEqual(self.focused(state).action, "other")
|
||||
self.assertIn("Every folder of this path would be made",
|
||||
" ".join(install.tui_view(state, 120, 40)))
|
||||
near = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
near = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, near, True)
|
||||
install._choose(state, "retroarch", near / "bios")
|
||||
self.assertEqual(self.focused(state).action, "create")
|
||||
@@ -2466,7 +2466,7 @@ class WorkFolders(unittest.TestCase):
|
||||
return [Key("enter")]
|
||||
|
||||
def run_to(self, code: int) -> tuple:
|
||||
work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
work = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, work, True)
|
||||
state = checked_state()
|
||||
state.stack.append("result")
|
||||
@@ -2547,7 +2547,7 @@ class WorkFolders(unittest.TestCase):
|
||||
entered = []
|
||||
WorkFolders.Terminal.state_to = lambda _t: None
|
||||
out = io.StringIO()
|
||||
work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
work = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, work, True)
|
||||
with mock.patch.object(install, "_TuiTerminal", self.Terminal), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
@@ -2585,7 +2585,7 @@ class CopyFromAnOldCard(unittest.TestCase):
|
||||
install.tui_receive(state, ("ended", state.run_id, 1, []))
|
||||
|
||||
def test_the_plan_offers_it_and_the_browser_adds_the_folder(self):
|
||||
old = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
old = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, old, True)
|
||||
(old / "bios").mkdir()
|
||||
(old / "backup.zip").write_bytes(b"PK")
|
||||
@@ -2730,7 +2730,7 @@ class CardsSpaceAndConfirm(unittest.TestCase):
|
||||
}
|
||||
|
||||
def card(self, files: dict) -> Path:
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
for name, text in files.items():
|
||||
path = root / name
|
||||
@@ -3266,7 +3266,7 @@ class CardsSpaceAndConfirm(unittest.TestCase):
|
||||
def test_work_folders_left_behind_are_pruned(self):
|
||||
import subprocess
|
||||
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
gone = subprocess.Popen([sys.executable, "-c", "pass"])
|
||||
gone.wait()
|
||||
@@ -3362,7 +3362,7 @@ class IdleExit(unittest.TestCase):
|
||||
return []
|
||||
|
||||
out = io.StringIO()
|
||||
work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
work = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, work, True)
|
||||
with mock.patch.object(install, "_TuiTerminal", Quiet), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
@@ -3492,7 +3492,7 @@ class TheSaveFolderHasARow(unittest.TestCase):
|
||||
self.assertEqual((row.label, row.right),
|
||||
(f"Save folder: {install._short_path(place.directory, HOME)}",
|
||||
"--save-dir"))
|
||||
saves = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
saves = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, saves, True)
|
||||
state.stack = ["setup", "plan", "options"]
|
||||
install._option(state, "savedir", 0)
|
||||
@@ -3517,7 +3517,7 @@ class ACardSystemNamedOnAComputer(unittest.TestCase):
|
||||
ONION = {".tmp_update/onionVersion/version.txt": "4.3.1\n"}
|
||||
|
||||
def card(self, files: dict) -> Path:
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
for name, text in files.items():
|
||||
(root / name).parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -3534,7 +3534,7 @@ class ACardSystemNamedOnAComputer(unittest.TestCase):
|
||||
self.assertIsNone(install.card_bound("batocera", "batocera"))
|
||||
|
||||
def test_without_questions_the_run_names_the_card_and_writes_nothing(self):
|
||||
home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, home, True)
|
||||
system = home / ".config" / "retroarch" / "system"
|
||||
system.mkdir(parents=True)
|
||||
@@ -4592,7 +4592,7 @@ class AFolderThisUserCannotOpen(unittest.TestCase):
|
||||
typed on the folder screen it ended on a crash log."""
|
||||
|
||||
def setUp(self):
|
||||
base = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
base = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, base, True)
|
||||
self.lock = base / "lock"
|
||||
self.lock.mkdir()
|
||||
@@ -4710,9 +4710,9 @@ class AGoesIntoASubfolder(unittest.TestCase):
|
||||
the BIOS files at its root) or .cache."""
|
||||
|
||||
def setUp(self):
|
||||
self.home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.home, True)
|
||||
self.card = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.card = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.card, True)
|
||||
self.state = install.TuiState(os_type="linux", home=self.home)
|
||||
self.state.platform = "retroarch"
|
||||
@@ -4879,7 +4879,7 @@ class WindowsHasNoPosixModules(unittest.TestCase):
|
||||
kill.assert_called_once_with(0, install.signal.CTRL_C_EVENT)
|
||||
|
||||
def test_work_folder_owner_and_partial_lock(self):
|
||||
work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
work = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, work, True)
|
||||
(work / install.TUI_OWNER).write_text(str(os.getpid()), encoding="utf-8")
|
||||
with SimulatedWindows() as windows:
|
||||
@@ -4897,7 +4897,7 @@ class WindowsHasNoPosixModules(unittest.TestCase):
|
||||
console.broken = True
|
||||
real_draw(terminal, lines, cols)
|
||||
|
||||
work = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
work = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, work, True)
|
||||
with SimulatedWindows() as windows, \
|
||||
mock.patch.object(install._TuiTerminal, "draw", breaking_draw), \
|
||||
@@ -5088,8 +5088,7 @@ def _app_card(test: unittest.TestCase, system: str) -> tuple[Path, Path]:
|
||||
"""A card of system in the repository's tmp/, its root and BIOS folder."""
|
||||
from tests.test_install_app import make_card
|
||||
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
test.addCleanup(shutil.rmtree, root, True)
|
||||
return root / "card", make_card(root / "card", system)
|
||||
|
||||
@@ -5242,7 +5241,6 @@ class EndToEnd(unittest.TestCase):
|
||||
"""The real install.py --tui, keys in and screens out."""
|
||||
|
||||
def repo(self, cls=FakeRepository, **options) -> FakeRepository:
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
repo = cls(**options)
|
||||
repo.__enter__()
|
||||
self.addCleanup(repo.__exit__, None, None, None)
|
||||
@@ -5828,8 +5826,7 @@ def _terminfo_folder(test: unittest.TestCase) -> Path:
|
||||
"""A $TERMINFO with a glass terminal, a VT52, two ANSI terminals of 8
|
||||
colours, one in the extended format, and two ANSI terminals without
|
||||
colour: one naming 2, one naming none (vt100)."""
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
folder = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
folder = Path(tempfile.mkdtemp())
|
||||
test.addCleanup(shutil.rmtree, folder, True)
|
||||
ansi = "\x1b[%i%p1%d;%p2%dH"
|
||||
for name, cup, extended, colours in (
|
||||
@@ -6334,7 +6331,7 @@ class CopyFromStartsInDownloads(unittest.TestCase):
|
||||
browser opened at HOME, under every mounted drive."""
|
||||
|
||||
def test_a_zip_in_downloads_opens_there(self):
|
||||
home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, home, True)
|
||||
(home / "Downloads").mkdir()
|
||||
state = checked_state()
|
||||
@@ -6372,7 +6369,7 @@ class AFocusesNoSystemFolder(unittest.TestCase):
|
||||
the recycle bin, which Use this folder then took as the BIOS folder."""
|
||||
|
||||
def setUp(self):
|
||||
self.home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.home, True)
|
||||
self.state = install.TuiState(os_type="linux", home=self.home)
|
||||
self.state.platform = "retroarch"
|
||||
@@ -6464,7 +6461,7 @@ class EveryCardSetupGoesToItsCard(unittest.TestCase):
|
||||
way in, goes to its card."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.setups = install.card_setups()
|
||||
|
||||
@@ -6686,7 +6683,7 @@ class ConfirmRefusalsAndCardRows(unittest.TestCase):
|
||||
"""Confirm before an install, refusals said in full, and card rows."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
|
||||
def onion(self, name: str = "ONION") -> Path:
|
||||
@@ -6968,7 +6965,7 @@ class OneCardReading(unittest.TestCase):
|
||||
of a card's root, said the same on the screen and in line mode."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
patcher = mock.patch.dict(install._DETECTED_OS, {})
|
||||
patcher.start()
|
||||
@@ -7228,7 +7225,7 @@ class WhatEachScreenOffers(unittest.TestCase):
|
||||
"""What each screen offers and says."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
|
||||
def setups(self, pad: str = "keys") -> install.TuiState:
|
||||
@@ -7953,7 +7950,7 @@ class LineModeAndScreenDecideAlike(_LineModeFindings, _OutsideTextFindings,
|
||||
platform and folder on both, A or Enter taking what each offers first."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
for patcher in (mock.patch.dict(install._DETECTED_OS, {}),
|
||||
mock.patch.dict(os.environ, {"HOME": str(self.root / "home"),
|
||||
@@ -9218,7 +9215,7 @@ class PacksWordingAndDocs(unittest.TestCase):
|
||||
LineModeAndScreenDecideAlike."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
install.LOCAL.reset()
|
||||
self.addCleanup(install.LOCAL.reset)
|
||||
@@ -9670,7 +9667,7 @@ class CardFoldersAndNarrowBars(unittest.TestCase):
|
||||
them."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
patcher = mock.patch.dict(install._DETECTED_OS, {})
|
||||
patcher.start()
|
||||
@@ -9855,7 +9852,7 @@ class CardBoundaries(unittest.TestCase):
|
||||
seen, a folder named MUOS taken for a card, ismount unprobed."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
|
||||
def choice(self, folder: Path, points=frozenset()) -> install.CardChoice:
|
||||
@@ -9909,7 +9906,7 @@ class LineModeDecisions(unittest.TestCase):
|
||||
no Enter default, a folder question with no way out)."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
for patcher in (mock.patch.dict(install._DETECTED_OS, {}),
|
||||
mock.patch.dict(os.environ, {"HOME": str(self.root / "home"),
|
||||
@@ -10093,7 +10090,7 @@ class ScreenRowsAndFilters(unittest.TestCase):
|
||||
"""Rows, filters and help as the screens draw them."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
patcher = mock.patch.dict(install._DETECTED_OS, {})
|
||||
patcher.start()
|
||||
@@ -10246,7 +10243,7 @@ class ScreenRowsAndFilters(unittest.TestCase):
|
||||
"""Cut after "copied,". On the CI runner /home
|
||||
held three folders, and the list cut the hint: it is kept whole,
|
||||
the list scrolling, from a folder of this test's own."""
|
||||
home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
home = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, home, True)
|
||||
for name in ("linuxbrew", "packer", "runner"):
|
||||
(home / name).mkdir()
|
||||
@@ -10372,8 +10369,7 @@ class EdgesTheMutantsFound(unittest.TestCase):
|
||||
Path("/mnt/g/RetroArch/cores")))
|
||||
|
||||
def card(self, system: str) -> Path:
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
make_card(root / "card", system)
|
||||
return root / "card"
|
||||
@@ -10420,8 +10416,7 @@ class CardNamesAndHelp(_CardFixtures, unittest.TestCase):
|
||||
docs answer, line mode's parity being in LineModeAndScreenDecideAlike."""
|
||||
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
install.LOCAL.reset()
|
||||
self.addCleanup(install.LOCAL.reset)
|
||||
@@ -10662,8 +10657,7 @@ class TheAndroidResultReadsWhole(unittest.TestCase):
|
||||
and the game data line named no folder."""
|
||||
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
for patcher in (mock.patch.dict(install._SPELLED, {}, clear=True),):
|
||||
patcher.start()
|
||||
@@ -11332,8 +11326,7 @@ class TapsGameDataAndExitCodes(_CardFixtures, unittest.TestCase):
|
||||
parity being in LineModeAndScreenDecideAlike."""
|
||||
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
install.LOCAL.reset()
|
||||
self.addCleanup(install.LOCAL.reset)
|
||||
@@ -12481,7 +12474,7 @@ class TheUsageNamesTheInstaller(unittest.TestCase):
|
||||
the name install.ps1 gives its copy."""
|
||||
|
||||
def test_a_copy_under_a_temporary_name_says_install_py(self):
|
||||
scratch = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
scratch = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, scratch, True)
|
||||
copy = scratch / "retrobios-install-33826e0b-37cc-4ad3-a6c4-6ed168e3fe9e.py"
|
||||
shutil.copyfile(REPO_ROOT / "install.py", copy)
|
||||
@@ -13642,7 +13635,7 @@ class EachDataTreeReadOnce(unittest.TestCase):
|
||||
on an SD card through a reader."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.dest = self.root / "bios"
|
||||
bios = b"bios bytes"
|
||||
@@ -15979,7 +15972,7 @@ class DeviceAndEmulatorScreens(unittest.TestCase):
|
||||
self.assertNotIn(("--offline", None), install.tui_flags(state))
|
||||
|
||||
def test_from_a_pack_opens_the_browser_on_zips_and_reads_the_pack(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "Downloads").mkdir()
|
||||
pack = root / "Downloads" / "RetroArch_BIOS_Pack.zip"
|
||||
@@ -16009,7 +16002,7 @@ class DeviceAndEmulatorScreens(unittest.TestCase):
|
||||
self.assertIn(("--from-pack", str(pack)), install.tui_flags(state))
|
||||
|
||||
def test_open_tui_pack_refuses_another_platforms_pack(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
pack = root / "Batocera_BIOS_Pack.zip"
|
||||
with zipfile.ZipFile(pack, "w") as archive:
|
||||
@@ -16071,7 +16064,7 @@ class ScreenChoicesInstallWhatTheirFlagInstalls(unittest.TestCase):
|
||||
patcher = mock.patch.object(install, "_mounted_cards", return_value=[])
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.listed, self.copies = _parity_list(self.root)
|
||||
self.manifest = json.loads(self.listed.read_text())
|
||||
@@ -16294,7 +16287,7 @@ class DeviceAndEmulatorReview(unittest.TestCase):
|
||||
self.assertEqual(state.packs, [])
|
||||
|
||||
def test_open_tui_pack_leaves_the_run_s_pack_alone(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
pack = root / "RetroArch_BIOS_Pack.zip"
|
||||
with zipfile.ZipFile(pack, "w") as archive:
|
||||
@@ -16310,7 +16303,7 @@ class DeviceAndEmulatorReview(unittest.TestCase):
|
||||
self.assertIs(install.LOCAL.pack, previous)
|
||||
|
||||
def test_a_zip_that_is_no_pack_is_closed(self):
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
notpack = root / "photos.zip"
|
||||
with zipfile.ZipFile(notpack, "w") as archive:
|
||||
|
||||
@@ -686,7 +686,7 @@ class _StalledResponse(io.BytesIO):
|
||||
|
||||
class DownloadFailuresAndRevisions(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = tempfile.mkdtemp(dir=REPO_ROOT / "tmp")
|
||||
self.dir = tempfile.mkdtemp()
|
||||
self._urlopen = largefiles.urllib.request.urlopen
|
||||
self.addCleanup(setattr, largefiles.urllib.request, "urlopen", self._urlopen)
|
||||
|
||||
@@ -794,7 +794,7 @@ class ASameSizeReuploadIsSeen(unittest.TestCase):
|
||||
--clobber: judged by size, the stale cache copy was kept for good."""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.cached = self.dir / "dsi_nand.bin"
|
||||
self.cached.write_bytes(b"OLD NAND")
|
||||
@@ -875,7 +875,7 @@ class AVerifiedPathKeepsItsBytes(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
_test_registry(self)
|
||||
self.dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
(self.dir / "asset.bin").write_bytes(PAYLOAD_A)
|
||||
self.served = {"asset.bin": hashlib.sha256(PAYLOAD_B).hexdigest()}
|
||||
|
||||
@@ -47,8 +47,7 @@ LINK = {
|
||||
class ALinkMovesTheDestination(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
bios = self.root / "bios" / "Commodore" / "Amiga"
|
||||
bios.mkdir(parents=True)
|
||||
@@ -306,8 +305,7 @@ class AProgramRunFromItsFolder(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
bios = self.root / "bios" / "Maker" / "Prog"
|
||||
bios.mkdir(parents=True)
|
||||
@@ -573,8 +571,7 @@ class ASettingSetsTheBiosFolder(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
files, by_md5, by_name = {}, {}, {}
|
||||
for folder, name, data in (
|
||||
|
||||
@@ -1592,7 +1592,7 @@ class Helpers(unittest.TestCase):
|
||||
from scraper import retrobat_scraper as rs
|
||||
|
||||
pin = "ca486005f598551600d04a33b3156a5d764368d6"
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as scratch:
|
||||
with tempfile.TemporaryDirectory() as scratch:
|
||||
yml = Path(scratch) / "retrobat.yml"
|
||||
yml.write_text(
|
||||
"source: https://raw.githubusercontent.com/RetroBat-Official/emulatorlauncher/"
|
||||
|
||||
@@ -80,8 +80,7 @@ PLATFORM = {
|
||||
|
||||
class _Collection(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self._tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self._cwd = os.getcwd()
|
||||
os.chdir(self._tmp.name)
|
||||
for relative, payload in (
|
||||
|
||||
@@ -22,7 +22,7 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
def _pack(*options: str) -> tuple[subprocess.CompletedProcess, list[str]]:
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out:
|
||||
with tempfile.TemporaryDirectory() as out:
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", *options, "--offline",
|
||||
"--output-dir", out],
|
||||
@@ -41,7 +41,6 @@ class TheEmulatorContextIsChecked(unittest.TestCase):
|
||||
db_path = REPO_ROOT / "database.json"
|
||||
if not db_path.exists():
|
||||
raise unittest.SkipTest("database.json is not built")
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
cls.db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
|
||||
def test_an_unknown_emulator_is_refused(self):
|
||||
@@ -79,7 +78,7 @@ class SystemAndEmulatorPacksKeepTheirNames(unittest.TestCase):
|
||||
import generate_db
|
||||
from packs import emulatorpack
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "bios").mkdir()
|
||||
(root / "emulators").mkdir()
|
||||
|
||||
@@ -132,8 +132,7 @@ class Workspace(unittest.TestCase):
|
||||
"""A tree with three records under measurements/ and one profile."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
(REPO_ROOT / "tmp" / "tests").mkdir(parents=True, exist_ok=True)
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
self.tmp = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
self.tree = self.tmp / "tree"
|
||||
self.tree.mkdir()
|
||||
@@ -473,7 +472,7 @@ class SitePages(unittest.TestCase):
|
||||
"""The Data page said each per-emulator database is "linked from its
|
||||
page". An emulator page shows the proof lines, which link the record
|
||||
lines and never the database."""
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as scratch:
|
||||
with tempfile.TemporaryDirectory() as scratch:
|
||||
path = Path(scratch) / "m.sqlite"
|
||||
connection = sqlite3.connect(path)
|
||||
connection.execute("CREATE TABLE meta (key TEXT)")
|
||||
|
||||
@@ -172,7 +172,7 @@ class PackPlacesCoreFilesUnderTheTag(unittest.TestCase):
|
||||
from model.profiles import emulator_profiles_cache
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
self.root = tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests")
|
||||
self.root = tempfile.mkdtemp()
|
||||
self.bios = os.path.join(self.root, "bios")
|
||||
self.platforms = os.path.join(self.root, "platforms")
|
||||
self.emulators = os.path.join(self.root, "emulators")
|
||||
@@ -385,7 +385,7 @@ class InstallerReadsTheCard(unittest.TestCase):
|
||||
"""install.py runs on the computer the card is mounted on."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
(self.root / ".system").mkdir()
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -20,7 +20,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class DeclaredSizeOrders(unittest.TestCase):
|
||||
def test_the_fitting_size_comes_first(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
big = Path(tmp) / "a" / "pcm.rom"
|
||||
small = Path(tmp) / "b" / "pcm.rom"
|
||||
for path, size in ((big, 1024), (small, 512)):
|
||||
|
||||
@@ -10,6 +10,7 @@ full manifest.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import scratch_dir
|
||||
|
||||
import contextlib
|
||||
import functools
|
||||
@@ -239,13 +240,8 @@ class InstallerLeavesGameDataOut(unittest.TestCase):
|
||||
"bios/game.wad": (b"wad" * 10, "game_data"),
|
||||
}
|
||||
|
||||
def _tempdir(self) -> Path:
|
||||
handle = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(handle.cleanup)
|
||||
return Path(handle.name)
|
||||
|
||||
def serve(self, categorized: bool = True) -> None:
|
||||
root = self._tempdir()
|
||||
root = scratch_dir(self)
|
||||
files = []
|
||||
for path, (data, category) in self.FILES.items():
|
||||
(root / path).parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -272,7 +268,7 @@ class InstallerLeavesGameDataOut(unittest.TestCase):
|
||||
threading.Thread(target=httpd.serve_forever, daemon=True).start()
|
||||
self.addCleanup(httpd.server_close)
|
||||
self.addCleanup(httpd.shutdown)
|
||||
home = self._tempdir()
|
||||
home = scratch_dir(self)
|
||||
self.bios = home / "bios"
|
||||
self.bios.mkdir()
|
||||
self.env = {**os.environ, "HOME": str(home), "RETROBIOS_OS": "linux",
|
||||
|
||||
@@ -36,8 +36,7 @@ def _entry(profile: str, name: str) -> dict:
|
||||
|
||||
class FontFormatsAreSeparateFiles(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.addCleanup(os.chdir, os.getcwd())
|
||||
os.chdir(self.root)
|
||||
|
||||
@@ -25,8 +25,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class ConformanceUsesTheRunDirectories(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
|
||||
def _args(self, split: bool) -> argparse.Namespace:
|
||||
|
||||
@@ -40,7 +40,7 @@ def _held(files: dict, by_name: dict, path: str, payload: bytes) -> str:
|
||||
|
||||
class CoreFilesAsTheBuilderPlacesThem(unittest.TestCase):
|
||||
def setUp(self):
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
@@ -96,7 +96,7 @@ class ARefusedPinLeavesItsPathToTheCore(unittest.TestCase):
|
||||
core file the pack carries there was never compared."""
|
||||
|
||||
def setUp(self):
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
@@ -152,7 +152,7 @@ class NarrowedPacksAgainstTheirOwnList(unittest.TestCase):
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import load_emulator_profiles, emulator_profiles_cache
|
||||
import generate_db
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
|
||||
@@ -643,7 +643,7 @@ class TheReleaseNotesReadTheRecord(unittest.TestCase):
|
||||
"- Every hash comes from the emulator's source, never from a forum list.\n"
|
||||
"- So a game never stops on a missing file."),
|
||||
["forum", "never stops"])
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
whats_new = Path(tmp) / "whats-new.md"
|
||||
whats_new.write_text("- Hashes never from a forum list\n", encoding="utf-8")
|
||||
record = Path(tmp) / "release.json"
|
||||
@@ -671,7 +671,7 @@ class CoreCopiesKeepTheirCategory(unittest.TestCase):
|
||||
def test_a_copy_counts_as_its_entry_says(self):
|
||||
from packs.extras import collect_emulator_extras, hidden_extras
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
held = Path(tmp) / "x.dat"
|
||||
held.write_bytes(b"data")
|
||||
sha1 = hashlib.sha1(b"data").hexdigest()
|
||||
|
||||
@@ -32,8 +32,7 @@ class _Fixture(unittest.TestCase):
|
||||
from model.profiles import emulator_profiles_cache
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.bios = self.root / "bios"
|
||||
self.platforms = self.root / "platforms"
|
||||
@@ -244,8 +243,7 @@ class ThePipelineComparesPaths(unittest.TestCase):
|
||||
def test_a_swap_at_equal_counts_fails(self):
|
||||
import pipeline
|
||||
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
zip_path = root / "Plat_BIOS_Pack.zip"
|
||||
with zipfile.ZipFile(zip_path, "w") as zf:
|
||||
|
||||
@@ -32,8 +32,7 @@ class FailedPlatformFailsTheRun(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
|
||||
def _args(self) -> argparse.Namespace:
|
||||
|
||||
@@ -27,7 +27,7 @@ class PackFileNames(unittest.TestCase):
|
||||
self.assertEqual(file_name_part('a\\b:c*d?"e<f>g|h', "_"), "a-b-c-d--e-f-g-h")
|
||||
|
||||
def test_an_emulator_named_with_a_slash_writes_its_pack(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
emulators = Path(tmp) / "emulators"
|
||||
out = Path(tmp) / "out"
|
||||
emulators.mkdir()
|
||||
@@ -56,7 +56,7 @@ class SystemPackLeavesTheEmulatorPack(unittest.TestCase):
|
||||
def test_both_packs_stay(self):
|
||||
import subprocess
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for mode in (["--emulator", "emuscv"], ["--system", "scv"]):
|
||||
subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", *mode, "--offline",
|
||||
|
||||
@@ -32,7 +32,7 @@ class MembersMustBeKnown(unittest.TestCase):
|
||||
with zipfile.ZipFile(inner, "w") as zf:
|
||||
zf.writestr("rom.bin", known)
|
||||
db = {"files": {}, "indexes": {"by_md5": {md5: "s"}, "by_name": {}}}
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
pack = Path(tmp) / "P_BIOS_Pack.zip"
|
||||
with zipfile.ZipFile(pack, "w") as zf:
|
||||
zf.writestr("clone.zip", inner.getvalue())
|
||||
@@ -50,7 +50,7 @@ class DataMembersAreCheckedByContent(unittest.TestCase):
|
||||
|
||||
def test_same_size_other_bytes_is_an_error(self):
|
||||
good = b"A" * 64
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache = Path(tmp) / "cache"
|
||||
(cache / "Sys").mkdir(parents=True)
|
||||
(cache / "Sys" / "font.bin").write_bytes(good)
|
||||
|
||||
@@ -19,6 +19,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
@@ -32,7 +33,7 @@ from model.profiles import load_emulator_profiles
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
TMP = REPO_ROOT / "tmp" / "tests" / "pack_probe"
|
||||
TMP = Path(tempfile.gettempdir()) / "pack_probe"
|
||||
|
||||
SATURN = {
|
||||
"type": "libretro",
|
||||
|
||||
@@ -233,7 +233,7 @@ class AlternativesAgreeWithThePack(unittest.TestCase):
|
||||
discrepancy, but verify took the worst status and said missing."""
|
||||
|
||||
def setUp(self):
|
||||
self._tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self._tmp.name)
|
||||
bios = self.root / "bios"
|
||||
self.emulators = self.root / "emulators"
|
||||
@@ -291,7 +291,7 @@ class AMaskedArchiveIsMissing(unittest.TestCase):
|
||||
def setUp(self):
|
||||
import zipfile
|
||||
|
||||
self._tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self._tmp.name)
|
||||
self.emulators = self.root / "emulators"
|
||||
files = {}
|
||||
|
||||
@@ -25,7 +25,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class AChildLeavesItsParentAlone(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_shared_yml_cache.clear)
|
||||
|
||||
+5
-13
@@ -9,6 +9,7 @@ route of the port, and the other launchers, are in test_handheld_launchers.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import scratch_dir
|
||||
|
||||
import hashlib
|
||||
import importlib.util
|
||||
@@ -19,7 +20,6 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
@@ -41,14 +41,6 @@ _spec.loader.exec_module(rbevents)
|
||||
SCRIPTS = [PORT / "RetroBIOS.sh", PORT / "retrobios" / "screens.txt"]
|
||||
|
||||
|
||||
def _tempdir(test: unittest.TestCase) -> Path:
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
path = Path(tempfile.mkdtemp(dir=str(scratch)))
|
||||
test.addCleanup(shutil.rmtree, path, True)
|
||||
return path
|
||||
|
||||
|
||||
class EveryScriptParses(unittest.TestCase):
|
||||
def test_only_dialog_functions_the_oldest_releases_have(self):
|
||||
"""PortMaster 2024.02.26 and 8.5.23 define these in PortMasterDialog.txt,
|
||||
@@ -78,7 +70,7 @@ class EveryScriptParses(unittest.TestCase):
|
||||
|
||||
class ThePortArchive(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.out = _tempdir(self)
|
||||
self.out = scratch_dir(self)
|
||||
|
||||
def _build(self, name: str = "RetroBIOS.zip") -> Path:
|
||||
return installer_build_port.build_port(self.out / name)
|
||||
@@ -154,7 +146,7 @@ class LauncherIndex(unittest.TestCase):
|
||||
def test_the_list_refuses_an_installer_the_bootstraps_do_not_pin(self):
|
||||
from installer_build import launcherindex
|
||||
|
||||
root = _tempdir(self)
|
||||
root = scratch_dir(self)
|
||||
shutil.copyfile(REPO_ROOT / "install.py", root / "install.py")
|
||||
(root / "install.sh").write_text('DEFAULT_INSTALL_SHA256="' + "0" * 64 + '"\n')
|
||||
with self.assertRaises(ValueError):
|
||||
@@ -331,7 +323,7 @@ class TheScreens(unittest.TestCase):
|
||||
"""Which screens the port shows, scenario by scenario."""
|
||||
|
||||
def run_port(self, scenario: str, answers: list[str], before=None, **env: str) -> list[tuple]:
|
||||
work = _tempdir(self)
|
||||
work = scratch_dir(self)
|
||||
(work / "install.py").write_text(FAKE_INSTALL)
|
||||
(work / "driver.sh").write_text(DRIVER)
|
||||
(work / "answers").write_text("".join(f"{a}\n" for a in answers))
|
||||
@@ -526,7 +518,7 @@ class TheScreens(unittest.TestCase):
|
||||
|
||||
def run_old(self, arch: str, **env: str) -> list[tuple]:
|
||||
"""A python3 on PATH that is 3.7.3, ahead of every other."""
|
||||
holder = _tempdir(self)
|
||||
holder = scratch_dir(self)
|
||||
fake = holder / "python3"
|
||||
fake.write_text('#!/bin/sh\n[ "$1" = "--version" ] && echo "Python 3.7.3"\nexit 1\n')
|
||||
fake.chmod(0o755)
|
||||
|
||||
@@ -83,8 +83,7 @@ class ProvenNameIndex(unittest.TestCase):
|
||||
|
||||
class HashlessEntryTakesTheProvenDump(unittest.TestCase):
|
||||
def test_resolver_reads_the_index(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
@@ -47,8 +47,7 @@ class _Response(io.BytesIO):
|
||||
|
||||
class RefreshConcurrency(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.root = Path(self.tmp.name)
|
||||
self.cache = self.root / "data" / "pak"
|
||||
@@ -218,7 +217,7 @@ class PackWalkHoldsTheCache(unittest.TestCase):
|
||||
import fcntl
|
||||
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache = Path(tmp) / "data" / "sdlpal"
|
||||
cache.mkdir(parents=True)
|
||||
(cache / "a.mkf").write_bytes(b"a")
|
||||
@@ -242,7 +241,7 @@ class EmulatorPackHoldsTheCache(unittest.TestCase):
|
||||
|
||||
from packs.datatrees import pack_data_tree
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache = Path(tmp) / "data" / "scummvm"
|
||||
cache.mkdir(parents=True)
|
||||
(cache / "a.dat").write_bytes(b"a")
|
||||
@@ -328,8 +327,7 @@ class TheManifestCarriesTheArchiveSize(unittest.TestCase):
|
||||
def test_recorded_size_is_written_and_an_unrecorded_one_left_out(self):
|
||||
from packs.datatrees import manifest_data_directories
|
||||
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
data = Path(tmp) / "data"
|
||||
for ref in ("pak", "old"):
|
||||
(data / ref).mkdir(parents=True)
|
||||
@@ -358,8 +356,7 @@ class ASourceThatMovesIsPinnedOrFollowed(unittest.TestCase):
|
||||
def _listed(self, registry: dict, versions: dict) -> dict[str, dict]:
|
||||
from packs.datatrees import manifest_data_directories
|
||||
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
data = Path(tmp) / "data"
|
||||
for ref, entry in registry.items():
|
||||
(data / ref).mkdir(parents=True)
|
||||
@@ -390,8 +387,7 @@ class ASourceThatMovesIsPinnedOrFollowed(unittest.TestCase):
|
||||
self.assertIs(listed["unrecorded"]["rolling"], True)
|
||||
|
||||
def test_a_branch_is_fetched_at_the_commit_it_records(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
versions = str(Path(tmp) / ".versions.json")
|
||||
entry = {"source_type": "zip", "version": "master", "strip_components": 1,
|
||||
"source_url": "https://github.com/o/r/archive/{version}.zip",
|
||||
|
||||
@@ -200,9 +200,7 @@ class AnEmptyExtractionKeepsTheCache(unittest.TestCase):
|
||||
directory, recorded the version and reported success."""
|
||||
|
||||
def setUp(self):
|
||||
scratch = Path(__file__).resolve().parent.parent / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=scratch))
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
self.cache = self.root / "cache"
|
||||
self.cache.mkdir()
|
||||
@@ -241,7 +239,7 @@ class TheVersionIsReadBeforeTheDownload(unittest.TestCase):
|
||||
def test_a_build_published_during_the_download(self):
|
||||
from packs import datadirs
|
||||
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
state = {"downloaded": False}
|
||||
|
||||
@@ -266,7 +264,7 @@ class ABadResponseIsTriedAgain(unittest.TestCase):
|
||||
failed the whole data step on it, and the next download was fine."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
self.versions = str(root / "versions.json")
|
||||
self.entry = {"source_type": "zip", "source_url": "https://example.invalid/S.zip",
|
||||
|
||||
@@ -197,8 +197,7 @@ class Running(unittest.TestCase):
|
||||
self.assertEqual(order.read_text().split(), ["parent", "child"])
|
||||
|
||||
def test_the_report_prints_verify_after_a_rescrape(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
log = Path(directory) / "x.log"
|
||||
log.write_text(
|
||||
"$ python -m scripts.scraper.x_scraper\nscraped\n"
|
||||
@@ -243,7 +242,7 @@ class SavedFindings(unittest.TestCase):
|
||||
nightly job checks every area once and refreshes only some."""
|
||||
|
||||
def test_rows_outside_the_asked_areas_are_left_out(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "freshness.json"
|
||||
path.write_text(
|
||||
'[{"area": "data", "subject": "dolphin-sys", "status": "STALE"},'
|
||||
@@ -259,7 +258,7 @@ class SavedFindings(unittest.TestCase):
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "freshness.json"
|
||||
path.write_text(json.dumps([
|
||||
finding("catalogs", "mame recipes"), finding("coreinfo", "anybor"),
|
||||
@@ -286,7 +285,7 @@ class SavedFindings(unittest.TestCase):
|
||||
self.assertEqual((jobs, [f["subject"] for f in surfaced]), ([], ["muos"]))
|
||||
|
||||
def test_a_report_that_is_not_a_list_is_refused(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "freshness.json"
|
||||
path.write_text('{"area": "data"}', encoding="utf-8")
|
||||
with self.assertRaises(RuntimeError):
|
||||
|
||||
@@ -1012,7 +1012,7 @@ class EmulatorModeKeepsAHeldFile(unittest.TestCase):
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
root = Path(tempfile.mkdtemp(dir=Path(__file__).resolve().parents[1] / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
held = root / "scph5501.bin"
|
||||
held.write_bytes(b"us bios")
|
||||
@@ -1315,9 +1315,7 @@ class ARefusedRegionalFileHoldsNoSlot(unittest.TestCase):
|
||||
from packs.emulatorcheck import verify_emulator
|
||||
|
||||
emulator_profiles_cache.clear()
|
||||
repo = Path(__file__).resolve().parents[1]
|
||||
(repo / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=repo / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
@@ -24,8 +24,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class ARefusedDumpHoldsNothing(unittest.TestCase):
|
||||
def test_held_follows_the_frontend(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
@@ -34,7 +34,6 @@ from model import releaserecord
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
PLATFORMS = str(REPO_ROOT / "platforms")
|
||||
TMP_ROOT = REPO_ROOT / "tmp"
|
||||
SITE = "https://abdess.github.io/retrobios/"
|
||||
# The owner's choice of 2026-10-23, from the download counts of v2026.10.10.
|
||||
RELEASED = {"retroarch", "emudeck", "retrobat", "batocera", "romm", "misterfpga"}
|
||||
@@ -68,7 +67,7 @@ class TheFieldIsTheList(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_only_marked_platforms_are_listed(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
platforms_dir = _write_registry(Path(tmp), {
|
||||
"big": {"release_pack": True},
|
||||
"small": {},
|
||||
@@ -132,7 +131,7 @@ class TheBuildReadsTheField(unittest.TestCase):
|
||||
def capture(args, groups, *rest, **kw):
|
||||
built.extend(name for group, _rep in groups for name in group)
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as out, \
|
||||
with tempfile.TemporaryDirectory() as out, \
|
||||
contextlib.chdir(REPO_ROOT), \
|
||||
mock.patch.object(generate_pack, "_run_platform_packs", capture), \
|
||||
mock.patch.object(generate_pack, "_run_manifest_mode", capture), \
|
||||
@@ -205,7 +204,7 @@ class APlatformWithoutAPackFailsNoCheck(unittest.TestCase):
|
||||
def test_verify_packs_sweeps_the_release_packs_only(self):
|
||||
import subprocess
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--all", "--verify-packs",
|
||||
"--output-dir", directory],
|
||||
@@ -452,7 +451,7 @@ class TheReleaseNotesThankPeople(unittest.TestCase):
|
||||
import release_notes
|
||||
from release import notes
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
tmp = Path(tmp)
|
||||
(tmp / "whats-new.md").write_text("### What changed\n\n- x\n", encoding="utf-8")
|
||||
(tmp / "thanks.md").write_text("- **Code and data**: @habib256.\n",
|
||||
@@ -562,7 +561,7 @@ class TheSiteCheckResolvesEveryGetPage(unittest.TestCase):
|
||||
"platforms": ["romm"], "assets": ["RomM_BIOS_Pack.zip"],
|
||||
"files": 1, "extracted_size": 1, "download_size": 1}}}
|
||||
download = validate.RELEASE_DOWNLOAD
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
record_path = root / "release.json"
|
||||
record_path.write_text(json.dumps(record), encoding="utf-8")
|
||||
|
||||
@@ -22,7 +22,7 @@ class RequiredOnlyArchives(unittest.TestCase):
|
||||
def test_optional_archives_stay_out(self):
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("database.json not built")
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "scripts/generate_pack.py", "--emulator", "geolith",
|
||||
"--required-only", "--offline", "--output-dir", tmp],
|
||||
|
||||
@@ -54,7 +54,7 @@ class WhatLeftIsRecorded(unittest.TestCase):
|
||||
self.assertEqual(model_retired.merge(again, {}, self.old), {})
|
||||
|
||||
def test_generate_db_writes_it_beside_the_database(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
database = Path(tmp) / "database.json"
|
||||
path = model_retired.retired_path(database)
|
||||
self.assertEqual(path, Path(tmp) / "retired.json")
|
||||
|
||||
@@ -28,7 +28,7 @@ PAYLOAD = b"romm firmware"
|
||||
|
||||
class SizeAndAnyHash(unittest.TestCase):
|
||||
def setUp(self):
|
||||
scratch = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
scratch = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(scratch.cleanup)
|
||||
self.path = str(Path(scratch.name) / "fw.bin")
|
||||
Path(self.path).write_bytes(PAYLOAD)
|
||||
|
||||
@@ -36,8 +36,7 @@ from core.hashing import git_blob_sha
|
||||
from core.torrentzip import build_torrentzip, is_torrentzip
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = ROOT / "tmp" / "tests"
|
||||
TMP_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
TMP_ROOT = Path(tempfile.gettempdir())
|
||||
|
||||
ROM_A = b"first rom payload"
|
||||
ROM_B = b"second rom payload"
|
||||
@@ -85,7 +84,7 @@ class RecipeCollection(unittest.TestCase):
|
||||
|
||||
class PoolAndBuild(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.bios = Path(self.temp.name)
|
||||
with zipfile.ZipFile(self.bios / "source.zip", "w") as archive:
|
||||
archive.writestr("a.rom", ROM_A)
|
||||
@@ -172,7 +171,7 @@ class ReportsOverAFixture(unittest.TestCase):
|
||||
"""A whole run over a synthetic collection, database and platform."""
|
||||
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.temp.name)
|
||||
self.bios = self.root / "bios"
|
||||
self.bios.mkdir()
|
||||
@@ -334,7 +333,7 @@ class DatRecipes(unittest.TestCase):
|
||||
self.assertEqual(entries, [])
|
||||
|
||||
def test_snapshot_round_trips_into_usable_recipes(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
snapshot = root / "romset-recipes.json"
|
||||
entries = recipe_entries(parse_logiqx(self._dat()))
|
||||
@@ -520,7 +519,7 @@ class ListXmlRecipes(unittest.TestCase):
|
||||
"""A .variants/ copy stands for the name its tag is cut from."""
|
||||
from scripts.scraper.romset_dat_importer import collection_archives, member_list
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as temp:
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
plain, variant = root / "set.zip", root / "other.zip.1a2b3c4d"
|
||||
for path in (plain, variant):
|
||||
@@ -568,7 +567,7 @@ class ListXmlRecipes(unittest.TestCase):
|
||||
self.assertTrue(holds_target([member], {(_crc(ROM_B), len(ROM_B)): {"a" * 40}}))
|
||||
|
||||
def test_catalog_targets_leave_out_what_the_collection_holds(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "prov").mkdir()
|
||||
(root / "prov" / "tosec.json").write_text(json.dumps({"source": "tosec", "entries": [
|
||||
@@ -588,7 +587,7 @@ class ListXmlRecipes(unittest.TestCase):
|
||||
"description": "",
|
||||
"members": [{"name": "a", "crc32": "1"}],
|
||||
}
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = str(Path(directory) / "fbneo.json")
|
||||
merge_snapshot(output, "fbneo", {"FBNeo - X": "1.0"}, [entry], {"X.dat": "aaa"})
|
||||
with open(output, encoding="utf-8") as handle:
|
||||
@@ -619,7 +618,7 @@ class ListXmlRecipes(unittest.TestCase):
|
||||
|
||||
def test_versions_accumulate_instead_of_replacing_each_other(self):
|
||||
"""A platform pins the archive of whichever version it was built on."""
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = str(Path(directory) / "romset-recipes.json")
|
||||
merge_snapshot(
|
||||
output,
|
||||
@@ -773,7 +772,7 @@ class IdentificationReadsTheDirectoryFirst(unittest.TestCase):
|
||||
|
||||
rom = b"rom bytes"
|
||||
crc = format(zlib.crc32(rom), "08x")
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
archive = Path(tmp) / "set.zip"
|
||||
archive.write_bytes(build_torrentzip([("a.rom", rom)]))
|
||||
|
||||
@@ -806,7 +805,7 @@ class BuildDigestsOutliveTheRun(unittest.TestCase):
|
||||
|
||||
from unittest import mock
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
bios = Path(tmp) / "bios"
|
||||
bios.mkdir()
|
||||
with zipfile.ZipFile(bios / "source.zip", "w") as archive:
|
||||
@@ -855,7 +854,7 @@ class AnOversizedDatIsNamed(unittest.TestCase):
|
||||
|
||||
from scripts.scraper.listxml import iter_dat_documents
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
pack = Path(directory) / "pack.zip"
|
||||
with zipfile.ZipFile(pack, "w") as archive:
|
||||
archive.writestr("big.dat", b"x" * 64)
|
||||
@@ -904,7 +903,7 @@ class FbneoFetchReadsOneRevision(unittest.TestCase):
|
||||
from scripts.scraper import romset_dat_importer as importer
|
||||
|
||||
self.importer = importer
|
||||
self._tmp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.dir = Path(self._tmp.name)
|
||||
self.calls: list[str] = []
|
||||
self.served = FBNEO_DAT
|
||||
@@ -977,7 +976,7 @@ class LooseRomsAreAtoms(unittest.TestCase):
|
||||
its one ROM sat loose in bios/Arcade/FBNeo/nmk004.bin."""
|
||||
|
||||
def test_a_loose_file_completes_a_recipe(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
bios = Path(directory) / "bios"
|
||||
bios.mkdir()
|
||||
loose = bios / "nmk004.bin"
|
||||
|
||||
@@ -147,9 +147,7 @@ class WithoutJsonschema(unittest.TestCase):
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
scratch = REPO_ROOT / "tmp" / "tests"
|
||||
scratch.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=scratch) as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
stub = Path(directory) / "jsonschema"
|
||||
stub.mkdir()
|
||||
(stub / "__init__.py").write_text(
|
||||
|
||||
@@ -994,7 +994,7 @@ class ImportingAScraperFetchesNothing(unittest.TestCase):
|
||||
self.assertEqual(self._offenders(REPO_ROOT, "scripts.scraper"), "")
|
||||
|
||||
def test_a_swallowed_import_time_fetch_is_caught(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
package = Path(directory) / "planted"
|
||||
package.mkdir()
|
||||
(package / "__init__.py").write_text("")
|
||||
@@ -1013,7 +1013,7 @@ class ImportingAScraperFetchesNothing(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_an_import_time_fetch_is_caught(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as directory:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
package = Path(directory) / "planted"
|
||||
package.mkdir()
|
||||
(package / "__init__.py").write_text("")
|
||||
|
||||
@@ -35,7 +35,6 @@ from scraper.base_scraper import (
|
||||
)
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
TMP_ROOT = REPO_ROOT / "tmp"
|
||||
SHA = "0123456789abcdef0123456789abcdef01234567"
|
||||
|
||||
|
||||
@@ -143,7 +142,7 @@ class SourceRevisionReadsEveryShape(unittest.TestCase):
|
||||
self.assertEqual(scraped_revision(Path(tmp, "absent.yml")), "")
|
||||
|
||||
def test_a_platform_without_a_revision_raises(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp, "p.yml")
|
||||
path.write_text("source: https://github.com/emulatorjs/emulatorjs\n")
|
||||
with self.assertRaises(RuntimeError):
|
||||
@@ -232,7 +231,7 @@ class GitHubAnswers(unittest.TestCase):
|
||||
|
||||
class Downloads(unittest.TestCase):
|
||||
def test_written_whole_with_its_disposition(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
target = Path(tmp, "sub", "a.zip")
|
||||
with mock.patch("urllib.request.urlopen", _answer(503, b"payload")), \
|
||||
mock.patch("time.sleep"):
|
||||
@@ -242,7 +241,7 @@ class Downloads(unittest.TestCase):
|
||||
self.assertEqual(sorted(p.name for p in target.parent.iterdir()), ["a.zip"])
|
||||
|
||||
def test_a_failure_leaves_nothing(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
target = Path(tmp, "a.zip")
|
||||
with mock.patch("urllib.request.urlopen", _answer(403)), \
|
||||
self.assertRaises(FetchError):
|
||||
@@ -250,7 +249,7 @@ class Downloads(unittest.TestCase):
|
||||
self.assertEqual(list(Path(tmp).iterdir()), [])
|
||||
|
||||
def test_an_existing_file_is_kept_when_asked(self):
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
target = Path(tmp, "a.zip")
|
||||
target.write_bytes(b"cached")
|
||||
with mock.patch("urllib.request.urlopen", _answer(403)):
|
||||
|
||||
@@ -224,9 +224,7 @@ class BoardRules(unittest.TestCase):
|
||||
board, a machine's own set is no board, contents: rejects a homonym."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
tmp_root = REPO_ROOT / "tmp"
|
||||
tmp_root.mkdir(exist_ok=True)
|
||||
self._tmp = tempfile.TemporaryDirectory(dir=tmp_root)
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self._tmp.name)
|
||||
systemnames.set_console_sections({("Arcade", "MAME"), ("SNK", "Neo Geo")})
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class AHeldEntrySaysWhere(unittest.TestCase):
|
||||
from sitegen import emulatorcards
|
||||
from packs.crossref import FileConsumers, held_copy
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
data, bios = Path(tmp) / "data", Path(tmp) / "bios"
|
||||
(data / "dolphin-sys" / "GC").mkdir(parents=True)
|
||||
(data / "dolphin-sys" / "GC" / "font_western.bin").write_bytes(b"font")
|
||||
|
||||
@@ -88,8 +88,7 @@ class ServedCopies(unittest.TestCase):
|
||||
self.assertEqual(sitebootstrap.build_commit(REPO_ROOT), self.commit)
|
||||
|
||||
def test_the_copies_land_at_the_root_of_the_public_folder(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir()
|
||||
else None) as scratch:
|
||||
with tempfile.TemporaryDirectory() as scratch:
|
||||
public = Path(scratch) / "public"
|
||||
written = sitebootstrap.write_bootstraps(public, REPO_ROOT, self.commit)
|
||||
self.assertEqual(sorted(p.name for p in written), ["i", "i.ps1"])
|
||||
@@ -117,8 +116,7 @@ class ServedCopies(unittest.TestCase):
|
||||
def test_a_stale_pin_stops_the_build(self):
|
||||
"""A pin that is not the installer's was served,
|
||||
and refused every install until the next good deploy."""
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir()
|
||||
else None) as scratch:
|
||||
with tempfile.TemporaryDirectory() as scratch:
|
||||
root = Path(scratch)
|
||||
for source in ("install.sh", "install.ps1"):
|
||||
(root / source).write_text((REPO_ROOT / source).read_text(encoding="utf-8"),
|
||||
@@ -143,8 +141,7 @@ class ServedCopies(unittest.TestCase):
|
||||
self.assertLess(check, upload)
|
||||
|
||||
def test_a_bootstrap_without_its_address_line_stops_the_build(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir()
|
||||
else None) as scratch:
|
||||
with tempfile.TemporaryDirectory() as scratch:
|
||||
root = Path(scratch)
|
||||
(root / "install.sh").write_text("#!/bin/sh\n", encoding="utf-8")
|
||||
with self.assertRaises(ValueError):
|
||||
|
||||
@@ -43,7 +43,7 @@ def _guides_text() -> str:
|
||||
class GuidesLiveInYaml(unittest.TestCase):
|
||||
|
||||
def _load(self, text: str, registry: dict | None = None) -> dict:
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "_guides.yml"
|
||||
path.write_text(text, encoding="utf-8")
|
||||
return load_guides(path, registry if registry is not None else _registry())
|
||||
@@ -171,7 +171,7 @@ class NavFromFrontMatter(unittest.TestCase):
|
||||
self.assertEqual(tabs["Reference"][0], "wiki/index.md")
|
||||
|
||||
def test_a_new_page_lands_in_its_tab_at_its_order(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
wiki = _wiki_copy(tmp)
|
||||
(wiki / "save-files.md").write_text(
|
||||
"---\nlevel: start\norder: 45\n---\n\n# Save files\n\nText.\n",
|
||||
@@ -183,7 +183,7 @@ class NavFromFrontMatter(unittest.TestCase):
|
||||
self.assertIn({"Save files": "wiki/save-files.md"}, start)
|
||||
|
||||
def test_a_page_without_a_level_fails_by_name(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
wiki = _wiki_copy(tmp)
|
||||
(wiki / "orphan.md").write_text("# Orphan\n\nText.\n", encoding="utf-8")
|
||||
with self.assertRaisesRegex(sitegen_nav.NavError,
|
||||
@@ -191,7 +191,7 @@ class NavFromFrontMatter(unittest.TestCase):
|
||||
self._nav(wiki)
|
||||
|
||||
def test_a_page_without_an_order_fails_by_name(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
wiki = _wiki_copy(tmp)
|
||||
(wiki / "orphan.md").write_text(
|
||||
"---\nlevel: reference\n---\n\n# Orphan\n", encoding="utf-8")
|
||||
@@ -202,7 +202,7 @@ class NavFromFrontMatter(unittest.TestCase):
|
||||
self._nav(wiki)
|
||||
|
||||
def test_two_pages_on_one_place_fail_naming_both(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
wiki = _wiki_copy(tmp)
|
||||
(wiki / "twin.md").write_text(
|
||||
"---\nlevel: contribute\norder: 20\n---\n\n# Twin\n", encoding="utf-8")
|
||||
@@ -211,7 +211,7 @@ class NavFromFrontMatter(unittest.TestCase):
|
||||
self._nav(wiki)
|
||||
|
||||
def test_nav_false_keeps_a_page_out(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
wiki = _wiki_copy(tmp)
|
||||
(wiki / "hidden.md").write_text(
|
||||
"---\nlevel: start\nnav: false\n---\n\n# Hidden\n", encoding="utf-8")
|
||||
|
||||
@@ -171,7 +171,7 @@ class WhatASearchSnippetSays(unittest.TestCase):
|
||||
import json
|
||||
import tempfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
page = Path(tmp) / "emulators" / "idtech4a++.md"
|
||||
page.parent.mkdir()
|
||||
page.write_text("# idTech4A++\n\nSome text long enough to be a description.\n")
|
||||
|
||||
@@ -383,8 +383,7 @@ class DataDirectoryPagesStayOutOfSearch(unittest.TestCase):
|
||||
class AnElementBudget(unittest.TestCase):
|
||||
def test_validate_site_reports_a_crowded_page(self):
|
||||
self.assertEqual(validate.MAX_PAGE_ELEMENTS, 10_000)
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
page = Path(tmp) / "crowded" / "index.html"
|
||||
page.parent.mkdir()
|
||||
page.write_text("<html><body>" + "<i></i>" * 10_001
|
||||
|
||||
@@ -27,9 +27,7 @@ ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class SiteReferenceContracts(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
scratch = ROOT / "tmp" / "tests"
|
||||
scratch.mkdir(parents=True, exist_ok=True)
|
||||
self.temp = tempfile.TemporaryDirectory(dir=scratch)
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.docs = Path(self.temp.name) / "docs"
|
||||
self.docs.mkdir()
|
||||
|
||||
@@ -713,7 +711,7 @@ class AHashFindsEveryPageThatNamesIt(unittest.TestCase):
|
||||
|
||||
body = b"approved inis\n"
|
||||
sha1 = hashlib.sha1(body).hexdigest()
|
||||
with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[1] / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
member = Path(tmp, "data", "dolphin-sys", "ApprovedInis.json")
|
||||
member.parent.mkdir(parents=True)
|
||||
member.write_bytes(body)
|
||||
@@ -771,7 +769,7 @@ class AHashFindsEveryPageThatNamesIt(unittest.TestCase):
|
||||
self.assertEqual(found[("emulator", "duckstation", "crc32", "11223344")]["name"], "m.rom")
|
||||
self.assertNotIn(("emulator", "an-alias", "md5", md5), found)
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[1] / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
shards = lookup.write_lookup_shards(Path(tmp), records, "2026-01-01T00:00:00Z")
|
||||
folder = Path(tmp) / "lookup"
|
||||
names = sorted(path.name for path in folder.glob("*.json"))
|
||||
@@ -796,7 +794,7 @@ class AnArchiveMemberIsFoundByItsCrc(unittest.TestCase):
|
||||
|
||||
from sitegen import lookup
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[1] / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
archive = root / "bios" / "Arcade" / "Arcade" / "a500.zip"
|
||||
archive.parent.mkdir(parents=True)
|
||||
@@ -930,7 +928,7 @@ class ACardNamesThePacksThatInstallIt(unittest.TestCase):
|
||||
from packs.crossref import FileConsumers
|
||||
from sitegen.cards import _installed_places
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "retrobat.json").write_text(_json.dumps({
|
||||
"platform": "retrobat",
|
||||
"files": [{"dest": "scph5501.bin", "sha1": "b" * 40,
|
||||
@@ -1062,7 +1060,7 @@ class ADataDirectoryFileCanBeLookedUp(unittest.TestCase):
|
||||
|
||||
from sitegen.lookup import data_directory_members, file_location_items
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "retroarch.json").write_text(_json.dumps({"data_directories": [
|
||||
{"ref": "dolphin-sys", "files": {"GC/font.bin": {"sha1": "c" * 40, "size": 3}}},
|
||||
]}))
|
||||
@@ -1267,7 +1265,7 @@ class EveryPageLinksItsOwnData(unittest.TestCase):
|
||||
|
||||
item = dataexports.system_export_item("sony", "Sony", {"PlayStation": [entry]})
|
||||
self.assertEqual(item["consoles"]["PlayStation"][0]["sha1"], "a" * 40)
|
||||
with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[1] / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "sony.json"
|
||||
dataexports.write_single_item(path, "systems", item, "2026-10-21T00:00:00Z")
|
||||
document = json.loads(path.read_text())
|
||||
|
||||
@@ -37,7 +37,7 @@ def _site(root: Path, words: str = "Words of the page.") -> Path:
|
||||
|
||||
class BuildStamp(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=ROOT / "tmp")
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.dist = _site(Path(self.tmp.name))
|
||||
pagemarkdown.convert_site(self.dist, STAMP)
|
||||
|
||||
@@ -63,7 +63,7 @@ class BuildStamp(unittest.TestCase):
|
||||
|
||||
def test_digests_ignore_the_build_line(self):
|
||||
first = json.loads((self.dist / "digests.json").read_text(encoding="utf-8"))
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as other:
|
||||
with tempfile.TemporaryDirectory() as other:
|
||||
dist = _site(Path(other))
|
||||
pagemarkdown.convert_site(dist, {"commit": "f" * 40, "date": "2026-11-10T00:00:00Z"})
|
||||
second = json.loads((dist / "digests.json").read_text(encoding="utf-8"))
|
||||
@@ -83,7 +83,7 @@ class IndexNowList(unittest.TestCase):
|
||||
def test_the_key_is_served_where_the_request_says(self):
|
||||
body = indexnow.payload(["https://abdess.github.io/retrobios/"])
|
||||
self.assertEqual(body["keyLocation"], "https://abdess.github.io/retrobios/indexnow.txt")
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as public:
|
||||
with tempfile.TemporaryDirectory() as public:
|
||||
written: dict[str, str] = {}
|
||||
siteagents.write(Path(public), [], lambda path, text: written.__setitem__(path, text))
|
||||
self.assertEqual(written[str(Path(public) / "indexnow.txt")].strip(), body["key"])
|
||||
|
||||
@@ -186,7 +186,7 @@ class EveryPageHasALevel(unittest.TestCase):
|
||||
self.assertIn(f"{level}: '{label}'", component)
|
||||
|
||||
def test_the_decoration_keeps_an_authored_level(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
page = Path(tmp) / "wiki" / "faq.md"
|
||||
page.parent.mkdir()
|
||||
page.write_text("---\nlevel: start\n---\n\n# FAQ\n\nQuestions people ask first.\n")
|
||||
|
||||
Loaded 100 of 127 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user