Skip to content

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

tests: read the venv folder, HOME and a directory the way Windows does

OpenCodeb147a2a5521f
diff --git a/tests/test_adb_key_fallback.py b/tests/test_adb_key_fallback.py
index fa9bf7614..b880ebd8e 100644
--- a/tests/test_adb_key_fallback.py
+++ b/tests/test_adb_key_fallback.py
@@ -175,7 +175,11 @@ class FallbackTest(unittest.TestCase):
(tools / "adbkey" / "adbkey.pub").write_text(OWN_PUB)
out = tmp / "key-out.txt"
- env = dict(os.environ, TV_HOST="127.0.0.1", HOME=str(home), KEY_OUT=str(out),
+ # Windows expands `~` from USERPROFILE, not HOME: without it tv.py reads the real
+ # ~/.android and generates its own key, so "the stock key wins" is never observed there.
+ home_var = {"USERPROFILE": str(home)} if os.name == "nt" else {}
+ env = dict(os.environ, TV_HOST="127.0.0.1", HOME=str(home), **home_var,
+ KEY_OUT=str(out),
PYTHONPATH=os.pathsep.join([str(tmp / "stub"), str(tools)]))
result = subprocess.run([sys.executable, str(tools / "tv.py"), "--probe"],
cwd=str(tmp), env=env, capture_output=True, text=True, timeout=120)
diff --git a/tests/test_agents_md.py b/tests/test_agents_md.py
index aa939cadf..c2ebeff9b 100644
--- a/tests/test_agents_md.py
+++ b/tests/test_agents_md.py
@@ -35,9 +35,23 @@ def text():
def ignored_prefixes():
- """Folders .gitignore names: they exist on a contributor's machine, not in a clone."""
- lines = (ROOT / ".gitignore").read_text(encoding="utf-8").split("\n")
- return [l.strip().rstrip("/") for l in lines if l.strip().endswith("/") and not l.startswith("#")]
+ """Folders .gitignore names: they exist on a contributor's machine, not in a clone.
+
+ An entry only counted as a folder while it ended in `/`, so `tools/venv` - which .gitignore
+ writes without one - was never in this list: the check then wanted `tools/venv/bin/pip` to
+ exist, which it does only because CI builds the venv before running the suite. A name whose
+ last part has no extension counts as a folder too, and on Windows that venv's `pip` lives in
+ `Scripts/`, not `bin/`.
+ """
+ folders = []
+ for line in (ROOT / ".gitignore").read_text(encoding="utf-8").split("\n"):
+ entry = line.strip()
+ if not entry or entry.startswith("#"):
+ continue
+ last = entry.rsplit("/", 1)[-1]
+ if entry.endswith("/") or ("*" not in entry and "." not in last):
+ folders.append(entry.rstrip("/"))
+ return folders
def file_names():
diff --git a/tests/test_check_command_line.py b/tests/test_check_command_line.py
index af6385546..2d2680bd9 100644
--- a/tests/test_check_command_line.py
+++ b/tests/test_check_command_line.py
@@ -155,7 +155,10 @@ class CheckCommandLineTest(unittest.TestCase):
result = self.run_check(str(self.base))
self.assertEqual(result.returncode, 2, result.stderr)
self.assertIn("could not read", result.stderr)
- self.assertIn("Is a directory", result.stderr)
+ # POSIX refuses a directory outright ("Is a directory"); Windows reports the same refusal as
+ # a permission error, since opening a directory is not a read that can start there.
+ self.assertTrue("Is a directory" in result.stderr or "denied" in result.stderr.lower(),
+ result.stderr)
self.assertNotIn("Traceback", result.stderr)
self.assertEqual(self.sent(), [])
diff --git a/tests/test_tv_help.py b/tests/test_tv_help.py
index dcbcfaf57..5e9e1d6c9 100644
--- a/tests/test_tv_help.py
+++ b/tests/test_tv_help.py
@@ -100,6 +100,10 @@ class TvHelpTest(unittest.TestCase):
mark, cmds = work / "mark", work / "cmds"
env = {k: v for k, v in os.environ.items() if k not in ("TV_HOST", "TV_PORT", "PYTHONPATH")}
env["HOME"] = str(self.home)
+ # Windows expands `~` from USERPROFILE, not HOME, so tv.py would read the real ~/.android
+ # and make a key of its own instead of the stock one this run put in the temporary home.
+ if os.name == "nt":
+ env["USERPROFILE"] = str(self.home)
env["STUB_MARK"], env["STUB_CMDS"] = str(mark), str(cmds)
if stub:
env["PYTHONPATH"] = str(self.base)