From 404445c68bc1818b2d99790487c990b7516d52f5 Mon Sep 17 00:00:00 2001 From: spark Date: Sat, 24 Oct 2026 18:26:48 +0000 Subject: [PATCH] q63: spark/verify_dir_analyzer -- asserts to _check(), so -O cannot print All verification tests passed on a zero-file subject --- wizard-work/spark/verify_dir_analyzer.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/wizard-work/spark/verify_dir_analyzer.py b/wizard-work/spark/verify_dir_analyzer.py index 6abd27f..89a49e7 100644 --- a/wizard-work/spark/verify_dir_analyzer.py +++ b/wizard-work/spark/verify_dir_analyzer.py @@ -4,23 +4,30 @@ import subprocess import json import sys + +def _check(cond, msg="check failed"): + """Explicit failure path -- survives `python3 -O`, where `assert` is compiled away.""" + if not cond: + raise SystemExit(f"FAIL: {msg}") + + # Test JSON mode result = subprocess.run(['python3', 'dir_analyzer.py', '/etc', '--json'], capture_output=True, text=True, cwd='/root/troupe-standup/wizard-work/spark') data = json.loads(result.stdout) -assert 'total_files' in data, "Missing total_files" -assert 'total_size_bytes' in data, "Missing total_size_bytes" -assert data['total_files'] > 0, "Should find files in /etc" -assert data['total_size_bytes'] > 0, "Should have size > 0" +_check('total_files' in data, "Missing total_files") +_check('total_size_bytes' in data, "Missing total_size_bytes") +_check(data['total_files'] > 0, "Should find files in /etc") +_check(data['total_size_bytes'] > 0, "Should have size > 0") print(f"JSON mode: PASS - {data['total_files']} files, {data['total_size_bytes']} bytes") # Test text mode result2 = subprocess.run(['python3', 'dir_analyzer.py', '/tmp'], capture_output=True, text=True, cwd='/root/troupe-standup/wizard-work/spark') -assert 'Total files:' in result2.stdout, "Should show file count" -assert 'Total size:' in result2.stdout, "Should show size" +_check('Total files:' in result2.stdout, "Should show file count") +_check('Total size:' in result2.stdout, "Should show size") print("Text mode: PASS") print("All verification tests passed") \ No newline at end of file