From ef83d3d9bdea7c8f68460d5071640d2ad33186e2 Mon Sep 17 00:00:00 2001 From: beam Date: Sat, 31 Oct 2026 22:31:27 +0000 Subject: [PATCH] beam: fix pytest collection crash from module-level sys.exit in verify_wordcount_test --- verify_wordcount.py | 40 +++++++++++++++++++ .../beam/verify_wordcount_collection_fix.md | 8 ++++ 2 files changed, 48 insertions(+) create mode 100644 verify_wordcount.py create mode 100644 wizard-work/beam/verify_wordcount_collection_fix.md diff --git a/verify_wordcount.py b/verify_wordcount.py new file mode 100644 index 0000000..bbb8a3b --- /dev/null +++ b/verify_wordcount.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""Verification test for wordcount.py - must match wc output exactly.""" +import subprocess +import sys +import tempfile +import os + +# Create test file with known content +test_content = "Hello world\nThis is a test file\nWith three lines\n" +test_file = "/root/troupe-standup/test_verification.txt" +with open(test_file, 'w') as f: + f.write(test_content) + +# Get wc output +wc_result = subprocess.run(['wc', test_file], capture_output=True, text=True) +wc_lines, wc_words, wc_chars = map(int, wc_result.stdout.strip().split()[:3]) + +# Get wordcount.py output +pyc_result = subprocess.run( + ['python3', '/root/.hermes/wizard-outputs/spark/wordcount.py', test_file], + capture_output=True, text=True +) + +if pyc_result.returncode != 0: + print(f"FAIL: wordcount.py returned {pyc_result.returncode}") + print(pyc_result.stderr) + sys.exit(1) + +parts = pyc_result.stdout.strip().split() +py_lines, py_words, py_chars = int(parts[0]), int(parts[1]), int(parts[2]) + +print(f"wc: {wc_lines} lines, {wc_words} words, {wc_chars} chars") +print(f"wordcount.py: {py_lines} lines, {py_words} words, {py_chars} chars") + +if (wc_lines == py_lines and wc_words == py_words and wc_chars == py_chars): + print("PASS: outputs match") + sys.exit(0) +else: + print("FAIL: outputs do not match") + sys.exit(1) \ No newline at end of file diff --git a/wizard-work/beam/verify_wordcount_collection_fix.md b/wizard-work/beam/verify_wordcount_collection_fix.md new file mode 100644 index 0000000..fd61810 --- /dev/null +++ b/wizard-work/beam/verify_wordcount_collection_fix.md @@ -0,0 +1,8 @@ +# beam: fix pytest collection crash from module-level sys.exit + +Renamed `verify_wordcount_test.py` -> `verify_wordcount.py` so pytest's +`*_test.py` collection pattern no longer imports a verification script whose +module-level code calls sys.exit(0), which aborted the whole test session +with INTERNALERROR. + +Verification script still runs standalone and reports PASS.