Skip to content

Commit 94ffa20

Browse files
author
Steven Tobin
committed
harden CSV correctness tests
1 parent 5428c7a commit 94ffa20

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_csv.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
from pathlib import Path
77
from typing import List
8+
from csv import reader as csv_reader
89

910

1011
def count_columns(file_name: Path) -> None:
@@ -15,14 +16,14 @@ def count_columns(file_name: Path) -> None:
1516
expected_column_count: int = 0
1617

1718
with open(file_name, mode="r", encoding="utf-8") as my_file:
18-
for line in my_file:
19-
19+
my_csv = csv_reader(my_file)
20+
for line in my_csv:
2021
# All lines must match the header of the file:
2122
if first_line:
2223
first_line = False
23-
expected_column_count = len(line.split(","))
24+
expected_column_count = len(line)
2425

25-
assert expected_column_count == len(line.split(","))
26+
assert expected_column_count == len(line)
2627

2728
def test_column_count() -> None:
2829
"""

0 commit comments

Comments
 (0)