diff --git a/tests/test_install_menu.py b/tests/test_install_menu.py index 52230115..82802f4f 100644 --- a/tests/test_install_menu.py +++ b/tests/test_install_menu.py @@ -1982,6 +1982,12 @@ def iterdir(path): return {'PYTHONPATH': str(imports)} def test_plain_install_updates_and_restarts_the_verified_fleet(self): + cache = ROOT / 'skills/orbi/scripts/__pycache__' + + def bytecode_snapshot(): + return {p.name: (hashlib.sha256(p.read_bytes()).hexdigest(), p.stat().st_mtime_ns) + for p in cache.glob('*.pyc')} + receipt, state, head = self.orbi_fleet_fixture() vendor = self.home / '.config/systemd/user/vendor-shell@.service' vendor.parent.mkdir(parents=True) @@ -1991,6 +1997,7 @@ def test_plain_install_updates_and_restarts_the_verified_fleet(self): state.write_text(json.dumps(states)) worker = Path(states['--system']['working-extra.service']['FragmentPath']) worker.write_text(worker.read_text().replace(' --config ', ' \\\n --config ')) + before_bytecode = bytecode_snapshot() result = self.install(env={'KIT_INSTALL_REPORT': str(receipt), **self.unreadable_root_fixture()}) self.assertEqual(result.returncode, 0, result.stdout + result.stderr) summary = result.stdout.split('Summary:', 1)[1] @@ -2026,7 +2033,7 @@ def test_plain_install_updates_and_restarts_the_verified_fleet(self): for d in ('paused', 'working'))) self.assertEqual(json.loads(state.read_text())['--user']['paused-worker.timer']['ActiveState'], 'active') self.assertEqual(self.calls('uv'), []) - self.assertFalse((ROOT / 'skills/orbi/scripts/__pycache__').exists()) + self.assertEqual(bytecode_snapshot(), before_bytecode, f'Bytecode changed in {cache}') def test_fleet_refresh_verifies_a_simple_timer_worker_that_exits_at_once(self): # Installed workers are Type=simple; a tick with no work ends with exit status 0. diff --git a/tests/test_orbi_control.py b/tests/test_orbi_control.py index ba69218d..53a7b7f2 100644 --- a/tests/test_orbi_control.py +++ b/tests/test_orbi_control.py @@ -8,6 +8,7 @@ preserve. """ import contextlib +import hashlib import importlib.util import io import json @@ -8729,9 +8730,16 @@ def test_help_keeps_python_floor_and_argparse_usage(self): self.assertRegex(result.stdout, rf'{action} \[(none|staging|scheduler)\]') def test_default_action_is_status_and_cli_uses_argv(self): + cache = HELPER.parent / '__pycache__' + + def bytecode_snapshot(): + return {p.name: (hashlib.sha256(p.read_bytes()).hexdigest(), p.stat().st_mtime_ns) + for p in cache.glob('*.pyc')} + with tempfile.TemporaryDirectory() as tmp: h = Harness(Path(tmp)) before = snapshot(h.home) + before_bytecode = bytecode_snapshot() result = subprocess.run( [sys.executable, '-B', str(HELPER), '--repo-dir', str(h.repo), '--json'], env=dict(h.env), capture_output=True, text=True, timeout=60) @@ -8740,7 +8748,7 @@ def test_default_action_is_status_and_cli_uses_argv(self): self.assertEqual(document['action'], 'status') self.assertEqual(document['deployment']['state'], 'absent') self.assertEqual(snapshot(h.home), before) - self.assertFalse((HELPER.parent / '__pycache__').exists()) + self.assertEqual(bytecode_snapshot(), before_bytecode, f'Bytecode changed in {cache}') def test_public_setup_mapping_is_shared_and_recovery_is_explicit(self): skill = (ROOT / 'skills/orbi/SKILL.md').read_text()