Skip to content

Commit

Permalink
Fix issue kurtmckee#318: test failures when cchardet is installed
Browse files Browse the repository at this point in the history
feedparser imports cchardet or chardet depending on what's installed:
https://github.com/kurtmckee/feedparser/blob/11990ea1d8791acc76c67781f1d2011daf0c3a99/feedparser/encodings.py#L37-L40

Although these libraries are mostly equivalent, they return slightly different
encoding strings, even though both are correct and lead to succesful decoding.
This change allows the tests to be run with either library by accepting both
encoding names as correct.

cchardet detects slightly different encodings from chardet,
  • Loading branch information
maksverver committed Aug 29, 2024
1 parent d27a9d9 commit 5613bfe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_encoding_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def test_prefix_file_wrapper(factory):
assert f.read() == b"abcdef"

f = feedparser.encodings.PrefixFileWrapper(b"abc", factory(b"def"))
assert f.read(2) == b"ab"
assert f.read(1) == b"a"
assert f.read(1) == b"b"
assert f.read() == b"cdef"


Expand Down

0 comments on commit 5613bfe

Please sign in to comment.