Skip to content

Commit

Permalink
Fixed the way the #1288 csv file test is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
qqAys committed Feb 19, 2024
1 parent f9e1e92 commit 72bc34e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ihatemoney/tests/import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def test_export(self):
'2016-12-31,red wine,XXX,200.0,jeanne,1.0,"zorglub, tata"',
'2016-12-31,fromage à raclette,10.0,XXX,zorglub,2.0,"zorglub, jeanne, tata, pépé"',
]
received_lines = resp.data.decode("utf-8").split("\n")
received_lines = resp.data.decode("utf-8-sig").split("\n")

for i, line in enumerate(expected):
assert set(line.split(",")) == set(received_lines[i].strip("\r").split(","))
Expand Down Expand Up @@ -457,7 +457,7 @@ def test_export(self):
"55.34,XXX,jeanne,tata",
"127.33,XXX,jeanne,zorglub",
]
received_lines = resp.data.decode("utf-8").split("\n")
received_lines = resp.data.decode("utf-8-sig").split("\n")

for i, line in enumerate(expected):
assert set(line.split(",")) == set(received_lines[i].strip("\r").split(","))
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_export_escape_formulae(self):
"date,what,amount,currency,payer_name,payer_weight,owers",
"2016-12-31,'=COS(36),10.0,EUR,zorglub,1.0,zorglub",
]
received_lines = resp.data.decode("utf-8").split("\n")
received_lines = resp.data.decode("utf-8-sig").split("\n")

for i, line in enumerate(expected):
assert set(line.split(",")) == set(received_lines[i].strip("\r").split(","))
Expand Down
2 changes: 1 addition & 1 deletion ihatemoney/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def csv2list_of_dicts(csv_to_convert):
"""Take a csv in-memory file and turns it into
a list of dictionnaries
"""
csv_file = TextIOWrapper(csv_to_convert, encoding="utf-8")
csv_file = TextIOWrapper(csv_to_convert, encoding="utf-8-sig")
reader = csv.DictReader(csv_file)
result = []
for r in reader:
Expand Down

0 comments on commit 72bc34e

Please sign in to comment.