Skip to content

Commit

Permalink
fix: always declare your file encoding, or Windows barfs
Browse files Browse the repository at this point in the history
I wish we could make CI use a different default encoding than utf8, so
CI would fail on these otherwise Windows-only errors!
  • Loading branch information
joanise committed Jul 19, 2022
1 parent b637ac8 commit 67de22f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions g2p/tests/test_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,22 @@ def test_g2p_studio_csv(self):
)
# Concatenate them (this is not a good idea) and make sure it works anyway
tf = NamedTemporaryFile(
prefix="test_g2p_g2p_", mode="w", suffix=".csv", delete=False
prefix="test_g2p_g2p_",
mode="w",
suffix=".csv",
delete=False,
encoding="utf8",
)
with open(
os.path.join(os.path.dirname(public_data), "mappings", "g2p_studio.csv")
os.path.join(os.path.dirname(public_data), "mappings", "g2p_studio.csv"),
encoding="utf8",
) as fh:
tf.write(fh.read())
# In fact you can't concatenate them anyway. They don't end in newline.
tf.write("\n")
with open(
os.path.join(os.path.dirname(public_data), "mappings", "g2p_studio2.csv")
os.path.join(os.path.dirname(public_data), "mappings", "g2p_studio2.csv"),
encoding="utf8",
) as fh:
tf.write(fh.read())
tf.close()
Expand Down

0 comments on commit 67de22f

Please sign in to comment.