From deed6ce23177cbd81ac58ef84d72dedd00a3a745 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 27 Jul 2021 19:48:27 +0100 Subject: [PATCH] Ensure chardet is installed when testing using tox Beautiful Soup uses chardet, if installed, to detect character encodings. This can lead to different test results based on whether chardet is installed or not. Requests < 2.26.0 requires chardet, but since 2.26.0 Requests requires charset_normalizer. Explicitly installing chardet maintains consistent test results. --- tests/test_parser.py | 3 +++ tox.ini | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/test_parser.py b/tests/test_parser.py index 63dd3447..93071453 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -195,5 +195,8 @@ class TestParser(unittest.TestCase): self.encoding_test(html, "ascii") def encoding_test(self, html, expected): + # If chardet is installed Beautiful Soup uses it for encoding detection. + # Results for html without a valid charset may differ + # based on chardet availability. soup = htmlsoup.make_soup(html) self.assertEqual(soup.original_encoding, expected) diff --git a/tox.ini b/tox.ini index e6918fdc..ca3fd921 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ envlist = py36, py37, py38, py39 [base] deps = + chardet pyftpdlib parameterized pdfminer