Skip to content

Commit 42e2202

Browse files
amar-pythonclaude
andcommitted
fix: suppress subprocess UTF-8 decode warnings in test runners
Add errors="replace" to subprocess.run() calls in test_regression.py, test_snapshot.py, and test_e2e_pipeline.py. The validator emits Windows-1252 bytes in its stderr color codes; replacing undecodable bytes prevents PytestUnhandledThreadExceptionWarning noise without affecting test correctness. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d80249b commit 42e2202

5 files changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,name,_skip_reason
2+
empty row — all values blank
3+
2,"column mismatch — expected 2, got 1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,name
2+
1,Alice
3+
3,Bob

tests/test_e2e_pipeline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def test_happy_path_two_valid_rows(self):
6060
r = subprocess.run(
6161
[sys.executable, str(VALIDATOR)],
6262
env=env, capture_output=True, text=True,
63+
encoding="utf-8", errors="replace",
6364
)
6465
self.assertEqual(r.returncode, 0, r.stderr)
6566
valid_lines = valid_csv.read_text(encoding="utf-8").strip().splitlines()
@@ -87,6 +88,7 @@ def test_mixed_rows_splits_correctly(self):
8788
r = subprocess.run(
8889
[sys.executable, str(VALIDATOR)],
8990
env=env, capture_output=True, text=True,
91+
encoding="utf-8", errors="replace",
9092
)
9193
self.assertEqual(r.returncode, 0, r.stderr)
9294
valid_lines = valid_csv.read_text(encoding="utf-8").strip().splitlines()
@@ -112,6 +114,7 @@ def test_all_invalid_rows_exit_nonzero(self):
112114
r = subprocess.run(
113115
[sys.executable, str(VALIDATOR)],
114116
env=env, capture_output=True, text=True,
117+
encoding="utf-8", errors="replace",
115118
)
116119
self.assertEqual(r.returncode, 1)
117120
self.assertIn("No valid rows", r.stderr)
@@ -133,6 +136,7 @@ def test_output_directory_is_created_automatically(self):
133136
r = subprocess.run(
134137
[sys.executable, str(VALIDATOR)],
135138
env=env, capture_output=True, text=True,
139+
encoding="utf-8", errors="replace",
136140
)
137141
# Either succeeds and created the dir, or fails with a clear message
138142
if r.returncode == 0:

tests/test_regression.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def _run(env: dict) -> subprocess.CompletedProcess:
2525
capture_output=True,
2626
text=True,
2727
encoding="utf-8",
28+
errors="replace",
2829
)
2930

3031

tests/test_snapshot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def _run_validator(csv_content: bytes, table_name: str = "people") -> tuple[str,
4444
capture_output=True,
4545
text=True,
4646
encoding="utf-8",
47+
errors="replace",
4748
)
4849
valid_text = valid_csv.read_text(encoding="utf-8") if valid_csv.exists() else ""
4950
skip_text = skip_csv.read_text(encoding="utf-8") if skip_csv.exists() else ""

0 commit comments

Comments
 (0)