Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid overly-specific assertion about charset-normalizer result #84

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ def test_empty_df():
assert actual.equals(expected)


@pytest.mark.parametrize(
"test_string,encoding",
[
(b"abcde", "utf-8"), # straight up ascii is a subset of unicode
(b"Eyjafjallaj\xc3\xb6kull", "utf-8"), # actual unicode
(b"\xC4pple", "cp037"), # non-unicode, ISO characterset
],
)
def test_detect_encoding(test_string, encoding):
assert detect_encoding(io.BytesIO(test_string)) == encoding
def test_detect_encoding():
# straight up ascii is a subset of unicode
assert detect_encoding(io.BytesIO(b"abcde")) == "utf-8"

# actual unicode
assert detect_encoding(io.BytesIO(b"Eyjafjallaj\xc3\xb6kull")) == "utf-8"

# non-unicode, ISO characterset
#
# (Note: we don't assert a specific characterset, because we don't want
# tests to break as changes are made in charset-normalizer. See:
# https://github.com/remix/partridge/pull/84)
enc = detect_encoding(io.BytesIO(b"\xC4pple"))
assert enc and enc != "utf-8"