mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
29 lines
571 B
Python
29 lines
571 B
Python
import csv
|
|
def test(data: str, expected):
|
|
ret = list(csv.reader(data.splitlines()))
|
|
assert ret==expected, f"Expected {expected}, got {ret}"
|
|
|
|
test("""a,b,c
|
|
1,2,3
|
|
""", [['a', 'b', 'c'], ['1', '2', '3']])
|
|
|
|
test("""a,b,c
|
|
1,2,"3"
|
|
""", [['a', 'b', 'c'], ['1', '2', '3']])
|
|
|
|
test("""a,b,c
|
|
1,2,'3'
|
|
""", [['a', 'b', 'c'], ['1', '2', '\'3\'']])
|
|
|
|
test('''a,b,c
|
|
1,2,"123"""
|
|
''', [['a', 'b', 'c'], ['1', '2', '123"']])
|
|
|
|
test("""a,b,c,
|
|
1,2,3,
|
|
""", [['a', 'b', 'c', ''], ['1', '2', '3', '']])
|
|
|
|
test("""a,b ,c,
|
|
1,"22""33",3
|
|
""", [['a', 'b ', 'c', ''], ['1', '22"33', '3']])
|