Skip to content

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

tests: the recovery suites set USERPROFILE on Windows, so records stay in the temporary home

editorrylix875f2aadae41
diff --git a/tests/test_home_guard.py b/tests/test_home_guard.py
index fa7b74ead..5417b5659 100644
--- a/tests/test_home_guard.py
+++ b/tests/test_home_guard.py
@@ -160,6 +160,9 @@ class HomeGuardTest(unittest.TestCase):
def disable(self, entry, extra_env=None, list_path=None):
env = dict(os.environ, TV_HOST="192.168.1.50", HOME=str(self.home),
FAKE_TV_STATE=str(self.state_path), **(extra_env or {}))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
if entry == "sh":
if os.name != "posix" or not shutil.which("bash"):
raise unittest.SkipTest("disable.sh is a POSIX script; it needs bash")
diff --git a/tests/test_recovery_commands_needs_host.py b/tests/test_recovery_commands_needs_host.py
index 9575bb6e9..8ff5ccf42 100644
--- a/tests/test_recovery_commands_needs_host.py
+++ b/tests/test_recovery_commands_needs_host.py
@@ -73,6 +73,9 @@ class NoTVHostTest(unittest.TestCase):
env = {key: value for key, value in os.environ.items()
if key not in ("TV_HOST", "TV_PORT")}
env["HOME"] = str(self.home)
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
if host is not None:
env["TV_HOST"] = host
return env
diff --git a/tests/test_recovery_record.py b/tests/test_recovery_record.py
index 17d46f0a2..0a85b2d00 100644
--- a/tests/test_recovery_record.py
+++ b/tests/test_recovery_record.py
@@ -416,6 +416,9 @@ class RecoveryRecordTest(unittest.TestCase):
def run_recovery(self, *args):
env = dict(os.environ, TV_HOST="192.168.1.50", HOME=str(self.home),
FAKE_TV_STATE=str(self.state_path))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
return subprocess.run(
[sys.executable, str(ROOT / "tools" / "recovery.py"), *args],
cwd=self.repo, env=env, capture_output=True, text=True, timeout=120,
diff --git a/tests/test_recovery_record_lan_address.py b/tests/test_recovery_record_lan_address.py
index f5d85da9b..990da8211 100644
--- a/tests/test_recovery_record_lan_address.py
+++ b/tests/test_recovery_record_lan_address.py
@@ -45,6 +45,9 @@ class RecordPerLanAddressTest(unittest.TestCase):
def run_script(self, script, host, port=None):
env = dict(os.environ, TV_HOST=host, HOME=str(self.home), FAKE_TV_STATE=str(self.state_path))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
env.pop("TV_PORT", None)
if port:
env["TV_PORT"] = port
diff --git a/tests/test_recovery_unreached_tv.py b/tests/test_recovery_unreached_tv.py
index 8d446c7be..ba8cd0d21 100644
--- a/tests/test_recovery_unreached_tv.py
+++ b/tests/test_recovery_unreached_tv.py
@@ -131,6 +131,9 @@ class Tree:
def run(self, *args, python_args=(), host="192.168.1.50", port=None, cwd=None):
env = dict(os.environ, HOME=str(self.home), FAKE_TV_STATE=str(self.state_path))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
env.pop("TV_ADB_BINARY", None)
env.pop("TV_PORT", None)
if host is None:
diff --git a/tests/test_restore_command_line.py b/tests/test_restore_command_line.py
index f7848b377..9b3e6084d 100644
--- a/tests/test_restore_command_line.py
+++ b/tests/test_restore_command_line.py
@@ -93,6 +93,9 @@ class RestoreCommandLineTest(unittest.TestCase):
def run_script(self, script, *args):
env = dict(os.environ, TV_HOST="192.168.1.50", HOME=str(self.home),
FAKE_TV_STATE=str(self.state_path))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
if script.endswith(".sh"):
if os.name != "posix" or not shutil.which("bash"):
raise unittest.SkipTest(f"{script} is a POSIX script; it needs bash")
diff --git a/tests/test_restore_stock_launcher.py b/tests/test_restore_stock_launcher.py
index f63c541ac..8c862d7dd 100644
--- a/tests/test_restore_stock_launcher.py
+++ b/tests/test_restore_stock_launcher.py
@@ -168,6 +168,9 @@ class RestoreStockLauncherTest(unittest.TestCase):
self.clear_sent()
env = dict(os.environ, TV_HOST="192.168.1.50", HOME=str(self.home),
FAKE_TV_STATE=str(self.state_path))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
result = subprocess.run([PWSH, "-NoProfile", "-File", str(tools / "restore.ps1"),
str(self.list_path)], cwd=self.repo, env=env, capture_output=True,
text=True, timeout=120)
diff --git a/tests/test_restore_venv_hint.py b/tests/test_restore_venv_hint.py
index 06e595e4f..3dc870a9a 100644
--- a/tests/test_restore_venv_hint.py
+++ b/tests/test_restore_venv_hint.py
@@ -75,6 +75,9 @@ class RestoreVenvHintTest(unittest.TestCase):
def run_script(self, script):
env = dict(os.environ, TV_HOST="192.168.1.50", HOME=str(self.home),
FAKE_TV_STATE=str(self.state_path))
+ # Path.home() reads USERPROFILE on Windows, not HOME: without it the record lands in the real ~.
+ if os.name == "nt":
+ env["USERPROFILE"] = env["HOME"]
if script.endswith(".sh"):
if os.name != "posix" or not shutil.which("bash"):
raise unittest.SkipTest(f"{script} is a POSIX script; it needs bash")