Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tests: the venv and TV_HOST hint checks expect the PowerShell wording on Windows

LOKI23ba181af26b
diff --git a/tests/test_manage_tv_status.py b/tests/test_manage_tv_status.py
index dc5a9f620..e4c03b4e0 100644
--- a/tests/test_manage_tv_status.py
+++ b/tests/test_manage_tv_status.py
@@ -29,7 +29,10 @@ import manage # noqa: E402
# tools/tv.py's own words for a port that refuses, the sentence manage.py re-emits.
REFUSED = ("127.0.0.1:1 refused the connection: nothing listens for ADB there, so network ADB is off or on "
"another port.")
-VENV_LINE = "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt"
+# The line manage.py prints is the PowerShell one on Windows, as tools/tv.py's is.
+VENV_LINE = (r"run: python -m venv tools\venv; .\tools\venv\Scripts\python.exe -m pip install -r "
+ r"tools\requirements.txt" if sys.platform == "win32" else
+ "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt")
def stop(call, *args, **kwargs):
@@ -51,9 +54,12 @@ class TvStatusTest(unittest.TestCase):
mock.patch.object(manage.subprocess, "run") as run:
code, err = stop(manage.tv, "pm list packages")
self.assertEqual(2, code)
- self.assertIn("set TV_HOST to the TV IP address", err)
- # tools/tv.py's own hint, which this line dropped when it was a one-line sys.exit
- self.assertIn("Settings → Network", err)
+ if sys.platform == "win32":
+ self.assertIn("set $env:TV_HOST to the TV IP address", err)
+ else:
+ self.assertIn("set TV_HOST to the TV IP address", err)
+ # tools/tv.py's own hint, which this line dropped when it was a one-line sys.exit
+ self.assertIn("Settings → Network", err)
self.assertIn("Nothing was asked of the TV.", err)
run.assert_not_called()
diff --git a/tests/test_trace_venv.py b/tests/test_trace_venv.py
index b04b00d18..670b014c7 100644
--- a/tests/test_trace_venv.py
+++ b/tests/test_trace_venv.py
@@ -44,6 +44,11 @@ MARKER = "CLEANYOURTV_TRACE_PY_VENV"
# tools/venv/bin/python, as the tests make it: it records what it was started with and stops there. A
# re-exec that never happened leaves no file, which is how "the venv was not started" is checked.
+# The line trace.py and tv.py print to make the venv: the PowerShell pair on Windows, the POSIX pair elsewhere.
+MAKE_VENV = (r"python -m venv tools\venv; tools\venv\Scripts\python.exe -m pip install -r tools\requirements.txt"
+ if os.name == "nt" else
+ "python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt")
+
STUB_VENV_PYTHON = """#!/bin/sh
printf '%s\\n' "$@" > "$TRACE_STUB_LOG"
exit 0
@@ -94,16 +99,17 @@ class TraceVenvTest(unittest.TestCase):
self.assertNotIn("Traceback", result.stderr)
self.assertIn("tools/trace.py needs the packages in tools/requirements.txt", result.stderr)
self.assertIn("No module named 'adb_shell'", result.stderr)
- self.assertIn("python3 -m venv tools/venv && tools/venv/bin/pip install -r "
- "tools/requirements.txt", result.stderr)
+ self.assertIn(MAKE_VENV, result.stderr)
self.assertEqual("", result.stdout)
self.assertEqual(None, self.started_with(), "no venv is there, and one was started anyway")
def test_the_line_is_the_one_tv_py_prints(self):
"""The hint names the same command the client itself prints, read out of tv.py rather than copied."""
client = (ROOT / "tools" / "tv.py").read_text(encoding="utf-8")
- match = re.search(r'"(python3 -m venv tools/venv && tools/venv/bin/pip install -r '
- r'tools/requirements\.txt)"', client)
+ pattern = (r'r"(python -m venv tools\\venv; tools\\venv\\Scripts\\python\.exe -m pip install -r '
+ r'tools\\requirements\.txt)"' if os.name == "nt" else
+ r'"(python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements\.txt)"')
+ match = re.search(pattern, client)
if match is None:
self.fail("tools/tv.py no longer carries the venv command this check reads")
command = match.group(1)
@@ -119,6 +125,7 @@ class TraceVenvTest(unittest.TestCase):
# ---- what a checkout with a venv does ------------------------------------------------------------
+ @unittest.skipIf(os.name == "nt", "the stand-in venv Python is a POSIX shell script; CI's Ubuntu runner runs it")
def test_the_venv_python_is_started_with_the_arguments_and_isolated(self):
self.stub_venv()
result = self.run_trace("home", "--runs", "1", "--out", "traces")