-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-104400: Add more tests to pygettext #108173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
06d86eb
b1b0892
eb7f488
7428393
f06cbb5
f4b7955
c6cb8b9
6a76d97
ebcc6ea
9dbc1c7
1c3d46a
cc4e663
1364705
a5501b8
e6b8c80
5fba1bb
9f388af
88f6350
f4ed4e4
63eef00
c26d488
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,3 +384,24 @@ def test_files_list(self): | |
self.assertIn(f'msgid "{text1}"', data) | ||
self.assertIn(f'msgid "{text2}"', data) | ||
self.assertNotIn(text3, data) | ||
|
||
|
||
def update_POT_snapshots(): | ||
for input_file in DATA_DIR.glob('*.py'): | ||
output_file = input_file.with_suffix('.pot') | ||
contents = input_file.read_text(encoding='utf-8') | ||
with temp_cwd(None): | ||
Path(input_file.name).write_text(contents) | ||
assert_python_ok(Test_pygettext.script, '--docstrings', input_file.name) | ||
output = Path('messages.pot').read_text() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you read text, always specify the encoding. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This causes problems on Windows, where the encoding is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use |
||
|
||
output = normalize_POT_file(output) | ||
output_file.write_text(output, encoding='utf-8') | ||
|
||
|
||
if __name__ == '__main__': | ||
# To regenerate POT files | ||
if len(sys.argv) > 1 and sys.argv[1] == '--snapshot-update': | ||
update_POT_snapshots() | ||
sys.exit(0) | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have some files with non-UTF-8 encoding.
Since
contents
is only used to copy a file, you can read/write the binary content.