bpo-31920: Fixed handling directories as arguments in the `pygettext` script. (GH-6259)

Based on patch by Oleg Krasnikov.
(cherry picked from commit c93938b5be)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-04-09 10:57:52 -07:00 committed by GitHub
parent 558e7e42be
commit 9b25bd6e26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 20 deletions

View file

@ -7,7 +7,7 @@ import textwrap
from test.support.script_helper import assert_python_ok
from test.test_tools import skip_if_missing, toolsdir
from test.support import temp_cwd
from test.support import temp_cwd, temp_dir
skip_if_missing()
@ -160,3 +160,27 @@ class Test_pygettext(unittest.TestCase):
"""doc"""
'''))
self.assertIn('doc', msgids)
def test_files_list(self):
"""Make sure the directories are inspected for source files
bpo-31920
"""
text1 = 'Text to translate1'
text2 = 'Text to translate2'
text3 = 'Text to ignore'
with temp_cwd(None), temp_dir(None) as sdir:
os.mkdir(os.path.join(sdir, 'pypkg'))
with open(os.path.join(sdir, 'pypkg', 'pymod.py'), 'w') as sfile:
sfile.write(f'_({text1!r})')
os.mkdir(os.path.join(sdir, 'pkg.py'))
with open(os.path.join(sdir, 'pkg.py', 'pymod2.py'), 'w') as sfile:
sfile.write(f'_({text2!r})')
os.mkdir(os.path.join(sdir, 'CVS'))
with open(os.path.join(sdir, 'CVS', 'pymod3.py'), 'w') as sfile:
sfile.write(f'_({text3!r})')
assert_python_ok(self.script, sdir)
with open('messages.pot') as fp:
data = fp.read()
self.assertIn(f'msgid "{text1}"', data)
self.assertIn(f'msgid "{text2}"', data)
self.assertNotIn(text3, data)