Skip to content

Commit

Permalink
Normalize charset
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr8 committed Aug 20, 2023
1 parent b1b0892 commit eb7f488
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Lib/test/test_tools/test_i18n/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def assert_POT_equal(self, expected, actual):
expected = re.sub(date_pattern, header, expected)
actual = re.sub(date_pattern, header, actual)

# Normalize charset (currently there's no way to specify the output charset)
charset_pattern = re.compile(r'"Content-Type: text/plain; charset=.+?\n"')
charset = "Content-Type: text/plain; charset=UTF-8\\n"
expected = re.sub(charset_pattern, charset, expected)
actual = re.sub(charset_pattern, charset, actual)

# Normalize the file location path separators in case this test is
# running on a platform which does not use '/' as a default separator
fileloc_pattern = re.compile(r'#:.+')
Expand Down Expand Up @@ -342,9 +348,9 @@ def test_pygettext_output(self):
with self.subTest(f'Input file: data/{input_file}'):
contents = (data_dir / input_file).read_text(encoding='utf-8')
with temp_cwd(None):
Path(input_file).write_text(contents, encoding='utf-8')
Path(input_file).write_text(contents)
assert_python_ok(self.script, '-D', input_file)
output = Path('messages.pot').read_text(encoding='utf-8')
output = Path('messages.pot').read_text()

expected = (data_dir / output_file).read_text(encoding='utf-8')
self.assert_POT_equal(expected, output)
Expand Down

0 comments on commit eb7f488

Please sign in to comment.