chore: merge origin/main

This commit is contained in:
Abdessamad Derraz committed 2026-11-09 20:01:25 +01:00
commit 7b90d94ebe
8 files changed
+75 -13

No files matched your search

+27
View File
@@ -7721,5 +7721,32 @@ class TheListVersionIsSaidBeforeAndAfter(unittest.TestCase):
self.assertNotIn("This list was built for", proc.stdout)
class APackageHintNamesThePackageCommand(unittest.TestCase):
"""Run from the retrobios package, a hint said `python3 install.py`,
a file the user does not have."""
def test_the_environment_names_the_command(self):
for prefix, command in (
("/home/me/.cache/uv/archive-v0/UwL4i3xOlCEYSTnw", "uvx retrobios"),
("C:\\Users\\me\\AppData\\Local\\uv\\cache\\archive-v0\\x1", "uvx retrobios"),
("/home/me/.cache/pipx/539b8243c11ee7c", "pipx run retrobios"),
("/home/me/.local/pipx/.cache/539b8243c11ee7c", "pipx run retrobios"),
("/home/me/.local/share/pipx/venvs/retrobios", "retrobios"),
("/home/me/.local/share/uv/tools/retrobios", "retrobios"),
("/home/me/venv", "retrobios"),
):
with self.subTest(prefix=prefix):
self.assertEqual(install.package_command(prefix), command)
def test_the_launcher_is_the_package_command(self):
hint = install.Invocation()
with unittest.mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "pypi"}), \
unittest.mock.patch.object(install.sys, "prefix", "/home/me/.cache/uv/archive-v0/a"):
self.assertEqual(hint.launcher(), "uvx retrobios")
self.assertEqual(hint.launcher(elevated=True), "sudo uvx retrobios")
self.assertTrue(hint.command("retroarch", "DIR").startswith(
"uvx retrobios --platform retroarch --dest DIR"))
if __name__ == "__main__":
unittest.main()
+18 -2
View File
@@ -186,8 +186,10 @@ class TheInstalledCommandIsTheInstaller(Built):
def _same_answers(self, python: str, name: str) -> None:
command = self._installed(python, name)
# `retrobios` and `python -m retrobios` both run install.py.
# `retrobios` and `python -m retrobios` both run install.py, whose
# examples then name the package command.
launchers = ([str(command)], [str(command.with_name("python")), "-m", "retrobios"])
as_package = {**os.environ, "RETROBIOS_BOOTSTRAP": "pypi"}
for launcher in launchers:
for args in (["--help"], ["--version"], ["--no-such-option"]):
with self.subTest(python=name, launcher=launcher[-1], args=args):
@@ -195,7 +197,7 @@ class TheInstalledCommandIsTheInstaller(Built):
text=True, check=False, cwd=self.scratch)
script = subprocess.run([python, str(REPO_ROOT / "install.py"), *args],
capture_output=True, text=True, check=False,
cwd=self.scratch)
cwd=self.scratch, env=as_package)
self.assertEqual(
(packaged.returncode, packaged.stdout, packaged.stderr),
(script.returncode, script.stdout, script.stderr))
@@ -203,6 +205,20 @@ class TheInstalledCommandIsTheInstaller(Built):
def test_this_python(self):
self._same_answers(sys.executable, "venv-current")
def test_a_hint_gives_back_the_package_command(self):
"""Nothing detected, the example said `python3 install.py`."""
command = self._installed(sys.executable, "venv-hint")
home = self.scratch / "empty-home"
home.mkdir()
env = {**os.environ, "HOME": str(home), "USERPROFILE": str(home),
"RETROBIOS_INSTALL_OFFLINE": "1"}
env.pop("RETROBIOS_BOOTSTRAP", None)
run = subprocess.run([str(command), "--yes"], capture_output=True, text=True,
check=False, cwd=self.scratch, env=env)
out = run.stdout + run.stderr
self.assertIn("retrobios --platform retroarch --dest", out)
self.assertNotIn("install.py --platform", out)
def test_python_38(self):
python = _python38()
if python is None: