From b69cae00b4a13cf306ec92d169b81c965a0865fc Mon Sep 17 00:00:00 2001 From: Jean Abou Samra Date: Mon, 30 Jan 2023 03:11:54 +0100 Subject: Fix lots of missing encoding="utf-8" parameters Some of these are probably unnecessary (ASCII-only content), but it's easier not to think about it. --- tests/contrast/test_contrasts.py | 4 ++-- tests/test_html_formatter_linenos_elements.py | 3 ++- tests/test_latex_formatter.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/contrast/test_contrasts.py b/tests/contrast/test_contrasts.py index 517b34ed..cfc9b414 100644 --- a/tests/contrast/test_contrasts.py +++ b/tests/contrast/test_contrasts.py @@ -60,7 +60,7 @@ def min_contrasts(): def update_json(): - with open(JSON_FILENAME, "w") as f: + with open(JSON_FILENAME, "w", encoding="utf-8") as f: json.dump( min_contrasts(), f, @@ -69,7 +69,7 @@ def update_json(): def test_contrasts(fail_if_improved=True): - with open(JSON_FILENAME) as f: + with open(JSON_FILENAME, encoding="utf-8") as f: previous_contrasts = json.load(f) for style_name in pygments.styles.STYLE_MAP: diff --git a/tests/test_html_formatter_linenos_elements.py b/tests/test_html_formatter_linenos_elements.py index 286b60c9..af43c4b4 100644 --- a/tests/test_html_formatter_linenos_elements.py +++ b/tests/test_html_formatter_linenos_elements.py @@ -57,7 +57,8 @@ def test_linenos_elements( # import bs4 as BeautifulSoup # f.write(str(BeautifulSoup.BeautifulSoup(html, 'html.parser'))) - with open(os.path.join(EXPECTED_OUTPUT_DIR, expected_html_filename)) as f: + with open(os.path.join(EXPECTED_OUTPUT_DIR, expected_html_filename), + encoding="utf-8") as f: expected_html = f.read() structural_diff.structural_diff(html, expected_html) diff --git a/tests/test_latex_formatter.py b/tests/test_latex_formatter.py index 42c5eda7..65b3bac1 100644 --- a/tests/test_latex_formatter.py +++ b/tests/test_latex_formatter.py @@ -24,7 +24,7 @@ TESTFILE = path.join(TESTDIR, 'test_latex_formatter.py') def test_correct_output(): - with open(TESTFILE) as fp: + with open(TESTFILE, encoding='utf-8') as fp: tokensource = list(PythonLexer().get_tokens(fp.read())) hfmt = LatexFormatter(nowrap=True) houtfile = StringIO() @@ -35,7 +35,7 @@ def test_correct_output(): def test_valid_output(): - with open(TESTFILE) as fp: + with open(TESTFILE, encoding='utf-8') as fp: tokensource = list(PythonLexer().get_tokens(fp.read())) fmt = LatexFormatter(full=True, encoding='latin1') -- cgit v1.2.1