Skip to content

Commit

Permalink
Simplify some file reading in tests by opening in text mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne authored and DimitriPapadopoulos committed Nov 27, 2022
1 parent 28ea98b commit 041bd02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ def test_case_handling(
code, _, stderr = result
assert code == 0
assert "FIXED" in stderr
with open(f.name, "rb") as fp:
assert fp.read().decode("utf-8") == "this has an ASCII error"
with open(f.name, encoding="utf-8") as fp:
assert fp.read() == "this has an ASCII error"


def _helper_test_case_handling_in_fixes(
Expand Down
8 changes: 4 additions & 4 deletions codespell_lib/tests/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def test_dictionary_formatting(
) -> None:
"""Test that all dictionary entries are valid."""
errors = []
with open(fname, "rb") as fid:
with open(fname, encoding="utf-8") as fid:
for line in fid:
err, rep = line.decode("utf-8").split("->")
err, rep = line.split("->")
err = err.lower()
rep = rep.rstrip("\n")
try:
Expand Down Expand Up @@ -259,9 +259,9 @@ def test_dictionary_looping(
"""Test that all dictionary entries are valid."""
this_err_dict = {}
short_fname = op.basename(fname)
with open(fname, "rb") as fid:
with open(fname, encoding="utf-8") as fid:
for line in fid:
err, rep = line.decode("utf-8").split("->")
err, rep = line.split("->")
err = err.lower()
assert err not in this_err_dict, "error %r already exists in %s" % (
err,
Expand Down

0 comments on commit 041bd02

Please sign in to comment.