Skip to content

gh-130197: Improve test coverage of msgfmt.py part 2 #133309

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove commented-out tests
  • Loading branch information
tomasr8 committed May 4, 2025
commit 6ba1488e67469ced05d0db9c5bd1f1bc9a3515d3
182 changes: 0 additions & 182 deletions Lib/test/test_tools/test_msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,29 +292,13 @@ def test_general_syntax_errors(self):
msgstr "bar"
''',

# invalid plural index
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# msgstr[foo] "baz"
# ''',

# invalid plural index
'''
msgid "foo"
msgid_plural "foos"
msgstr[0 "baz"
''',

# invalid plural index
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# msgstr[] "baz"
# ''',

# invalid plural index
'''
msgid "foo"
Expand All @@ -341,90 +325,6 @@ def test_general_syntax_errors(self):

def test_semantic_errors(self):
invalid_po_files = (
# missing msgid after msgctxt
# invalid but currently accepted
# 'msgctxt "foo"',

# missing msgstr after msgid
# invalid but currently accepted
# 'msgid "foo"',

# comment line not allowed after msgctxt
# invalid but currently accepted
# '''
# msgctxt "foo"
# # comment
# msgid "bar"
# msgstr "bar"
# ''',

# comment line not allowed after msgid
# invalid but currently accepted
# '''
# msgid "foo"
# # comment
# msgstr "bar"
# ''',

# comment line not allowed after msgid_plural
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# # comment
# msgstr[0] "bar"
# ''',

# msgctxt not allowed after msgctxt
# invalid but currently accepted
# '''
# msgctxt "foo"

# msgctxt "bar"
# msgid "foo"
# msgstr "bar"
# ''',

# msgctxt not allowed after msgid
# invalid but currently accepted
# '''
# msgid "foo"
# msgctxt "bar"

# msgid "bar"
# msgstr "baz"
# ''',

# msgctxt not allowed after msgid_plural
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# msgctxt "bar"

# msgid "bar"
# msgstr "baz"
# ''',

# msgid not allowed after msgid
# invalid but currently accepted
# '''
# msgid "foo"

# msgid "bar"
# msgstr "baz"
# ''',

# msgid not allowed after msgid_plural
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"

# msgid "bar"
# msgstr "baz"
# ''',

# msgid_plural must be preceded by msgid
'''
msgid_plural "foos"
Expand All @@ -442,17 +342,6 @@ def test_semantic_errors(self):
msgstr "baz"
''',

# msgid_plural not allowed after msgid_plural
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# msgid_plural "bars"

# msgid "bar"
# msgstr "baz"
# ''',

# msgid_plural not allowed after msgctxt
'''
msgctxt "foo"
Expand Down Expand Up @@ -480,16 +369,6 @@ def test_semantic_errors(self):
msgstr "baz"
''',

# msgstr not allowed after comment
# invalid but currently accepted
# '''
# # comment
# # msgstr "foo"

# msgid "bar"
# msgstr "baz"
# ''',

# msgstr not allowed after msgctxt
'''
msgctxt "foo"
Expand All @@ -499,17 +378,6 @@ def test_semantic_errors(self):
msgstr "bar"
''',

# msgstr not allowed after msgstr
# invalid but currently accepted
# '''
# msgid "foo"
# msgstr "bar"
# msgstr "baz"

# msgid "bar"
# msgstr "baz"
# ''',

# missing msgid_plural section
'''
msgid "foo"
Expand All @@ -530,23 +398,6 @@ def test_semantic_errors(self):

def test_msgstr_invalid_indices(self):
invalid_po_files = (
# wrong plural form index
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# msgstr[42] "bar"
# ''',

# wrong plural form index
# invalid but currently accepted
# '''
# msgid "foo"
# msgid_plural "foos"
# msgstr[0] "bar"
# msgstr[42] "bars"
# ''',

# msgstr not pluralized
'''
msgid "foo"
Expand All @@ -563,39 +414,6 @@ def test_msgstr_invalid_indices(self):
with self.assertRaises(SystemExit):
msgfmt.make('messages.po', 'messages.mo')

def test_duplicate_entries(self):
invalid_po_files = (
# duplicate msgid
# invalid but currently accepted
# '''
# msgid "foo"
# msgstr "bar"

# msgid "foo"
# msgstr "baz"
# ''',

# duplicate msgctxt+msgid
# invalid but currently accepted
# '''
# msgctxt "context"
# msgid "foo"
# msgstr "bar"

# msgctxt "context"
# msgid "foo"
# msgstr "baz"
# '''
)
with temp_cwd():
for invalid_po in invalid_po_files:
with self.subTest(invalid_po=invalid_po):
Path('messages.po').write_text(invalid_po)
# Reset the global MESSAGES dictionary
msgfmt.MESSAGES.clear()
with self.assertRaises(SystemExit):
msgfmt.make('messages.po', 'messages.mo')


class CLITest(unittest.TestCase):

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy