gh-130197: pygettext: Test the --escape option (GH-131902)

This commit is contained in:
Tomas R. 2025-04-02 10:46:54 +02:00 committed by GitHub
parent e7980ba233
commit 87d9983994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 138 additions and 3 deletions

View file

@ -526,11 +526,21 @@ def extract_from_snapshots():
'custom_keywords.py': ('--keyword=foo', '--keyword=nfoo:1,2',
'--keyword=pfoo:1c,2',
'--keyword=npfoo:1c,2,3', '--keyword=_:1,2'),
# == Test character escaping
# Escape ascii and unicode:
'escapes.py': ('--escape', '--add-comments='),
# Escape only ascii and let unicode pass through:
('escapes.py', 'ascii-escapes.pot'): ('--add-comments=',),
}
for filename, args in snapshots.items():
input_file = DATA_DIR / filename
output_file = input_file.with_suffix('.pot')
if isinstance(filename, tuple):
filename, output_file = filename
output_file = DATA_DIR / output_file
input_file = DATA_DIR / filename
else:
input_file = DATA_DIR / filename
output_file = input_file.with_suffix('.pot')
contents = input_file.read_bytes()
with temp_cwd(None):
Path(input_file.name).write_bytes(contents)