From 3023ac33ec95e83b2be17b4e57b4934cf351d7c7 Mon Sep 17 00:00:00 2001 From: martino <32328813+f3rs3n@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:58:09 +0200 Subject: [PATCH] test(monitor): support discovery without TMPDIR --- .github/workflows/test-offline-qualified.yml | 4 ++++ .../tests/test_health_persistence_recurrence.py | 12 ++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-offline-qualified.yml b/.github/workflows/test-offline-qualified.yml index d16ed340..29af7416 100644 --- a/.github/workflows/test-offline-qualified.yml +++ b/.github/workflows/test-offline-qualified.yml @@ -60,6 +60,10 @@ jobs: env: PYTHONDONTWRITEBYTECODE: '1' run: python3 -I -B .github/scripts/run_offline_qualified.py --lane python + - name: Run health recurrence tests without TMPDIR + env: + PYTHONDONTWRITEBYTECODE: '1' + run: env -u TMPDIR python3 -I -B -m unittest discover -s AppImage/scripts/tests -p test_health_persistence_recurrence.py -v offline-node: runs-on: ubuntu-latest diff --git a/AppImage/scripts/tests/test_health_persistence_recurrence.py b/AppImage/scripts/tests/test_health_persistence_recurrence.py index 651d1e06..8c3c78ab 100644 --- a/AppImage/scripts/tests/test_health_persistence_recurrence.py +++ b/AppImage/scripts/tests/test_health_persistence_recurrence.py @@ -1,10 +1,11 @@ """Offline recurrence tests against the complete, real persistence module. From the repository root (stdlib only; no broad test discovery): - TMPDIR=/path/to/private/scratch python3 -I -B -m unittest discover \ + python3 -I -B -m unittest discover \ -s AppImage/scripts/tests -p test_health_persistence_recurrence.py -v -TMPDIR must already exist and must not be the system temporary directory. +Each test creates and removes its own private temporary directory. +No temporary-directory environment variable is required. Only the data-directory Path boundary and datetime clock are redirected, before module execution (including the real global constructor). No persistence method is stubbed. Every test has its own real SQLite DB. Audit guards constrain DB @@ -101,12 +102,7 @@ class FrozenDatetime(datetime): class HealthPersistenceRecurrenceTests(unittest.TestCase): def setUp(self): global _AUDIT_SCOPE - scratch = os.environ.get('TMPDIR') - if not scratch or not Path(scratch).is_dir(): - self.fail('Set TMPDIR to an existing private scratch directory') - if Path(scratch).resolve() in (Path('/tmp'), Path('/var/tmp')): - self.fail('System temporary directories are not allowed') - temporary = tempfile.TemporaryDirectory(prefix='health-recurrence-', dir=scratch) + temporary = tempfile.TemporaryDirectory(prefix='health-recurrence-') self.addCleanup(temporary.cleanup) self.data_dir = Path(temporary.name) self.scope = {'root': self.data_dir, 'db': self.data_dir / 'health_monitor.db',