mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 04:48:54 -06:00
refactor: share the loopback server of the tests
Each installer test module rebuilt the same loopback fixture: a silent SimpleHTTPRequestHandler, a ThreadingHTTPServer on a daemon thread with its two cleanups, closed_port(), noise() and the CRC-32 text. tests/loopback.py holds them once; handlers with their own behaviour (Slow, Range, Held) pass in as handler=. The test_install servers that set log_message on a functools.partial, which never reached the handler, now use the quiet one. The journeys comment says why their root stays in tmp/.
This commit is contained in:
1 parent
13db912e52
commit
98775b7e4d
15 files changed
+144
-285
No files matched your search
@@ -10,6 +10,7 @@ to one answer.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests import loopback
|
||||
from tests.sources import script_source
|
||||
|
||||
import contextlib
|
||||
@@ -520,11 +521,6 @@ class TheBoundaryChecksTheNewFields(unittest.TestCase):
|
||||
install._validate_manifest(manifest, "retroarch")
|
||||
|
||||
|
||||
class _QuietHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def log_message(self, format, *args):
|
||||
return
|
||||
|
||||
|
||||
class FakeRepository:
|
||||
"""A loopback copy of the repository: one manifest and its payloads."""
|
||||
|
||||
@@ -562,7 +558,7 @@ class FakeRepository:
|
||||
files.append(entry)
|
||||
manifest = {"manifest_version": 2, "platform": "retroarch", "files": files}
|
||||
(self.root / "install" / "retroarch.json").write_text(json.dumps(manifest))
|
||||
handler = functools.partial(_QuietHandler, directory=str(self.root))
|
||||
handler = functools.partial(loopback.Quiet, directory=str(self.root))
|
||||
self.httpd = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler)
|
||||
threading.Thread(target=self.httpd.serve_forever, daemon=True).start()
|
||||
self.dest = self.root / "dest"
|
||||
|
||||
Reference in new issue
Block a user