mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
chore: hoist test imports to module level
This commit is contained in:
1 parent
38655d1d23
commit
913ba09600
9 files changed
+31
-47
No files matched your search
@@ -16,8 +16,8 @@ from pathlib import Path
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
from common import load_platform_config, load_platform_registry
|
from common import load_platform_config, load_platform_registry # noqa: E402
|
||||||
from generate_readme import extract_notes, extract_targets
|
from generate_readme import extract_notes, extract_targets # noqa: E402
|
||||||
|
|
||||||
PLATFORMS = str(REPO_ROOT / "platforms")
|
PLATFORMS = str(REPO_ROOT / "platforms")
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ from pathlib import Path
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
from cross_reference import FileConsumers
|
from cross_reference import FileConsumers # noqa: E402
|
||||||
from generate_site import generate_system_page
|
from generate_site import generate_system_page # noqa: E402
|
||||||
|
|
||||||
_TMP = tempfile.TemporaryDirectory()
|
_TMP = tempfile.TemporaryDirectory()
|
||||||
_ROOT = Path(_TMP.name)
|
_ROOT = Path(_TMP.name)
|
||||||
|
|||||||
@@ -10,17 +10,23 @@ exercised is a promise to contributors backed by nothing.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import importlib
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
import urllib.error
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
|
from scraper import emudeck_scraper, libretro_scraper # noqa: E402
|
||||||
from scraper.base_scraper import ( # noqa: E402
|
from scraper.base_scraper import ( # noqa: E402
|
||||||
BaseScraper,
|
BaseScraper,
|
||||||
BiosRequirement,
|
BiosRequirement,
|
||||||
ChangeSet,
|
ChangeSet,
|
||||||
|
fetch_github_latest_version,
|
||||||
|
github_headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -238,14 +244,9 @@ class UnreadableReleaseStopsTheScrape(unittest.TestCase):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _refuse(*_args, **_kwargs):
|
def _refuse(*_args, **_kwargs):
|
||||||
import urllib.error
|
|
||||||
|
|
||||||
raise urllib.error.HTTPError("https://api.github.com/x", 403, "rate limited", {}, None)
|
raise urllib.error.HTTPError("https://api.github.com/x", 403, "rate limited", {}, None)
|
||||||
|
|
||||||
def test_every_pinned_scraper_raises(self):
|
def test_every_pinned_scraper_raises(self):
|
||||||
import importlib
|
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
for name in (
|
for name in (
|
||||||
"scraper.bizhawk_scraper",
|
"scraper.bizhawk_scraper",
|
||||||
"scraper.romm_scraper",
|
"scraper.romm_scraper",
|
||||||
@@ -259,45 +260,29 @@ class UnreadableReleaseStopsTheScrape(unittest.TestCase):
|
|||||||
module.Scraper()
|
module.Scraper()
|
||||||
|
|
||||||
def test_a_release_lookup_raises(self):
|
def test_a_release_lookup_raises(self):
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
from scraper.base_scraper import fetch_github_latest_version
|
|
||||||
|
|
||||||
with mock.patch("urllib.request.urlopen", self._refuse), self.assertRaises(
|
with mock.patch("urllib.request.urlopen", self._refuse), self.assertRaises(
|
||||||
RuntimeError
|
RuntimeError
|
||||||
):
|
):
|
||||||
fetch_github_latest_version("libretro/RetroArch")
|
fetch_github_latest_version("libretro/RetroArch")
|
||||||
|
|
||||||
def test_the_token_is_sent(self):
|
def test_the_token_is_sent(self):
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
from scraper.base_scraper import github_headers
|
|
||||||
|
|
||||||
with mock.patch.dict("os.environ", {"GITHUB_TOKEN": "t0k"}):
|
with mock.patch.dict("os.environ", {"GITHUB_TOKEN": "t0k"}):
|
||||||
self.assertEqual(github_headers()["Authorization"], "Bearer t0k")
|
self.assertEqual(github_headers()["Authorization"], "Bearer t0k")
|
||||||
|
|
||||||
def test_emudeck_cores_raise(self):
|
def test_emudeck_cores_raise(self):
|
||||||
"""EmuDeck wrote cores: [] when the GitHub listing was refused."""
|
"""EmuDeck wrote cores: [] when the GitHub listing was refused."""
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
from scraper.emudeck_scraper import Scraper
|
|
||||||
|
|
||||||
with mock.patch("urllib.request.urlopen", self._refuse), self.assertRaises(
|
with mock.patch("urllib.request.urlopen", self._refuse), self.assertRaises(
|
||||||
RuntimeError
|
RuntimeError
|
||||||
):
|
):
|
||||||
Scraper()._fetch_installed_emulators()
|
emudeck_scraper.Scraper()._fetch_installed_emulators()
|
||||||
|
|
||||||
def test_libretro_core_metadata_raises(self):
|
def test_libretro_core_metadata_raises(self):
|
||||||
"""libretro dropped every system name and manufacturer when the
|
"""libretro dropped every system name and manufacturer when the
|
||||||
core-info listing was refused."""
|
core-info listing was refused."""
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
from scraper.libretro_scraper import Scraper
|
|
||||||
|
|
||||||
with mock.patch("urllib.request.urlopen", self._refuse), self.assertRaises(
|
with mock.patch("urllib.request.urlopen", self._refuse), self.assertRaises(
|
||||||
RuntimeError
|
RuntimeError
|
||||||
):
|
):
|
||||||
Scraper()._fetch_core_metadata()
|
libretro_scraper.Scraper()._fetch_core_metadata()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ import yaml
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
from generate_site import _availability_check, _file_badges
|
from common import load_database # noqa: E402
|
||||||
|
from generate_site import _availability_check, _file_badges # noqa: E402
|
||||||
|
|
||||||
SHA1 = "a" * 40
|
SHA1 = "a" * 40
|
||||||
DB = {
|
DB = {
|
||||||
@@ -40,8 +41,6 @@ class UnsourceableIsNotHeld(unittest.TestCase):
|
|||||||
self.assertNotIn("in repo", badges)
|
self.assertNotIn("in repo", badges)
|
||||||
|
|
||||||
def test_no_profile_entry_is_shown_held(self):
|
def test_no_profile_entry_is_shown_held(self):
|
||||||
from common import load_database
|
|
||||||
|
|
||||||
db_path = REPO_ROOT / "database.json"
|
db_path = REPO_ROOT / "database.json"
|
||||||
if not db_path.exists():
|
if not db_path.exists():
|
||||||
self.skipTest("database.json is not built")
|
self.skipTest("database.json is not built")
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import yaml
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
import common
|
import common # noqa: E402
|
||||||
from common import build_zip_contents_index, compute_hashes
|
from common import build_zip_contents_index, compute_hashes # noqa: E402
|
||||||
from generate_pack import generate_split_packs
|
from generate_pack import generate_split_packs # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
class SplitPartNames(unittest.TestCase):
|
class SplitPartNames(unittest.TestCase):
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@@ -26,6 +27,7 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
|
|||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
import generate_pack as builder # noqa: E402
|
import generate_pack as builder # noqa: E402
|
||||||
|
from artifacts import artifact_lock # noqa: E402
|
||||||
import split_pack # noqa: E402
|
import split_pack # noqa: E402
|
||||||
|
|
||||||
LIMIT = 4096
|
LIMIT = 4096
|
||||||
@@ -141,10 +143,6 @@ class SplitHoldsTheDirectory(SplitFixture):
|
|||||||
the pack the build had just written."""
|
the pack the build had just written."""
|
||||||
|
|
||||||
def test_a_held_directory_is_left_alone(self):
|
def test_a_held_directory_is_left_alone(self):
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from artifacts import artifact_lock
|
|
||||||
|
|
||||||
for target in (self.dist, self.pack):
|
for target in (self.dist, self.pack):
|
||||||
with self.subTest(target=target.name), artifact_lock(str(self.dist)):
|
with self.subTest(target=target.name), artifact_lock(str(self.dist)):
|
||||||
proc = subprocess.run(
|
proc = subprocess.run(
|
||||||
|
|||||||
@@ -11,12 +11,16 @@ standalone_cores dropped them from its pack.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
|
from cross_reference import cross_reference # noqa: E402
|
||||||
|
|
||||||
DUAL_PROFILE = {
|
DUAL_PROFILE = {
|
||||||
"emulator": "Dual",
|
"emulator": "Dual",
|
||||||
@@ -73,11 +77,6 @@ class CrossReferenceReadsTheBuildThePlatformRuns(unittest.TestCase):
|
|||||||
where verify and the pack builder found 26."""
|
where verify and the pack builder found 26."""
|
||||||
|
|
||||||
def _gaps(self, standalone_cores):
|
def _gaps(self, standalone_cores):
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
|
||||||
from cross_reference import cross_reference
|
|
||||||
|
|
||||||
empty_db = {"files": {}, "indexes": {}}
|
empty_db = {"files": {}, "indexes": {}}
|
||||||
report = cross_reference(
|
report = cross_reference(
|
||||||
{"dual": DUAL_PROFILE}, {}, empty_db, standalone_cores=standalone_cores
|
{"dual": DUAL_PROFILE}, {}, empty_db, standalone_cores=standalone_cores
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ from pathlib import Path
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
from common import build_target_cores_cache
|
from common import build_target_cores_cache # noqa: E402
|
||||||
from generate_pack import _target_cores_for
|
from generate_pack import _target_cores_for # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
class CheckReadsTheTargetLikeTheBuild(unittest.TestCase):
|
class CheckReadsTheTargetLikeTheBuild(unittest.TestCase):
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ from pathlib import Path
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||||
|
|
||||||
from truth import _diff_system, _match_renames, _merge_file_into_system # noqa: E402
|
from truth import ( # noqa: E402
|
||||||
|
_diff_system,
|
||||||
|
_match_renames,
|
||||||
|
_merge_file_into_system,
|
||||||
|
generate_platform_truth,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _entry(name: str, **hashes) -> dict:
|
def _entry(name: str, **hashes) -> dict:
|
||||||
@@ -205,8 +210,6 @@ class OnlySystemDirectoryEntries(unittest.TestCase):
|
|||||||
verify deliberately leave them out of."""
|
verify deliberately leave them out of."""
|
||||||
|
|
||||||
def test_a_file_read_elsewhere_is_not_asked_of_the_platform(self):
|
def test_a_file_read_elsewhere_is_not_asked_of_the_platform(self):
|
||||||
from truth import generate_platform_truth
|
|
||||||
|
|
||||||
profiles = {
|
profiles = {
|
||||||
"core": {
|
"core": {
|
||||||
"emulator": "Core",
|
"emulator": "Core",
|
||||||
|
|||||||
Reference in new issue
Block a user