Skip to content

Commit a63b463

Browse files
lesnik512claude
andcommitted
test(story-1.6): subprocess-based import-isolation guard for opt-in extras
Verifies that `import httpware` does not transitively load msgspec. msgspec is installed in the test env (via --all-extras), so the check runs in a fresh subprocess with a clean sys.modules. Future stories (5-4 otel) extend this file with their own subprocess tests for each opt-in extra. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5f647c4 commit a63b463

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Verify that `import httpware` does not transitively load opt-in extras."""
2+
3+
import subprocess
4+
import sys
5+
6+
7+
def test_importing_httpware_does_not_import_msgspec() -> None:
8+
"""Fresh subprocess: msgspec must NOT appear in sys.modules after `import httpware`.
9+
10+
msgspec IS installed in the test environment (via `--all-extras`), so this
11+
test runs in a subprocess with a clean interpreter to verify that nothing
12+
in the httpware import chain pulls msgspec in.
13+
"""
14+
result = subprocess.run(
15+
[
16+
sys.executable,
17+
"-c",
18+
"import httpware; import sys; "
19+
"sys.exit(0 if 'msgspec' not in sys.modules else 1)",
20+
],
21+
check=False,
22+
capture_output=True,
23+
)
24+
assert result.returncode == 0, (
25+
"msgspec was loaded transitively by `import httpware`; "
26+
f"stdout={result.stdout!r} stderr={result.stderr!r}"
27+
)

0 commit comments

Comments
 (0)