summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJakub Kuczys <me@jacken.men>2022-10-15 14:57:53 (GMT)
committerGitHub <noreply@github.com>2022-10-15 14:57:53 (GMT)
commit120b4ab2b68aebf96ce0de243eab89a25fc2d282 (patch)
tree1fc1b9e2dabb77c995fddebd19f0b0f2c1beea8e /Lib/test
parent07b5c4699e64eb30c3bdcb1275c167e675d37423 (diff)
downloadcpython-120b4ab2b68aebf96ce0de243eab89a25fc2d282.zip
cpython-120b4ab2b68aebf96ce0de243eab89a25fc2d282.tar.gz
cpython-120b4ab2b68aebf96ce0de243eab89a25fc2d282.tar.bz2
gh-95731: Fix module docstring extraction in pygettext (#95732)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_tools/test_i18n.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_tools/test_i18n.py b/Lib/test/test_tools/test_i18n.py
index 7f18eda..c083a04 100644
--- a/Lib/test/test_tools/test_i18n.py
+++ b/Lib/test/test_tools/test_i18n.py
@@ -155,6 +155,26 @@ class Test_pygettext(unittest.TestCase):
'''))
self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
+ def test_moduledocstring(self):
+ for doc in ('"""doc"""', "r'''doc'''", "R'doc'", 'u"doc"'):
+ with self.subTest(doc):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ %s
+ ''' % doc))
+ self.assertIn('doc', msgids)
+
+ def test_moduledocstring_bytes(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ b"""doc"""
+ '''))
+ self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
+
+ def test_moduledocstring_fstring(self):
+ msgids = self.extract_docstrings_from_str(dedent('''\
+ f"""doc"""
+ '''))
+ self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
+
def test_msgid(self):
msgids = self.extract_docstrings_from_str(
'''_("""doc""" r'str' u"ing")''')