FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test_cli: add formatted_frozen_time · python-babel/babel@1ae1c21 · GitHub

Commit 1ae1c21

Browse files
committed
test_cli: add formatted_frozen_time
1 parent 7c27207 commit 1ae1c21

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

‎tests/messages/frontend/test_cli.py‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_help(cli):
110110
assert all(command in content for command in ('init', 'update', 'compile', 'extract'))
111111

112112

113-
def test_extract_with_default_mapping(frozen_time, cli, pot_file):
113+
def test_extract_with_default_mapping(formatted_frozen_time, cli, pot_file):
114114
cli.run([
115115
'pybabel',
116116
'extract',
@@ -122,7 +122,6 @@ def test_extract_with_default_mapping(frozen_time, cli, pot_file):
122122
'-c', 'TRANSLATORS:',
123123
'-o', pot_file, 'project',
124124
]) # fmt: skip
125-
date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
126125
expected_content = fr"""# Translations template for TestProject.
127126
# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
128127
# This file is distributed under the same license as the TestProject
@@ -134,7 +133,7 @@ def test_extract_with_default_mapping(frozen_time, cli, pot_file):
134133
msgstr ""
135134
"Project-Id-Version: TestProject 0.1\n"
136135
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
137-
"POT-Creation-Date: {date}\n"
136+
"POT-Creation-Date: {formatted_frozen_time}\n"
138137
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
139138
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
140139
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -165,7 +164,13 @@ def test_extract_with_default_mapping(frozen_time, cli, pot_file):
165164
assert expected_content == pot_file.read_text()
166165

167166

168-
def test_extract_with_mapping_file(frozen_time, cli, pot_file):
167+
@pytest.fixture()
168+
def formatted_frozen_time(frozen_time) -> str:
169+
"""Freeze time and return it formatted for PO use"""
170+
return format_datetime(frozen_time, 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
171+
172+
173+
def test_extract_with_mapping_file(formatted_frozen_time, cli, pot_file):
169174
cli.run([
170175
'pybabel',
171176
'extract',
@@ -178,7 +183,6 @@ def test_extract_with_mapping_file(frozen_time, cli, pot_file):
178183
'-c', 'TRANSLATORS:',
179184
'-o', pot_file, 'project',
180185
]) # fmt: skip
181-
date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
182186
expected_content = fr"""# Translations template for TestProject.
183187
# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
184188
# This file is distributed under the same license as the TestProject
@@ -190,7 +194,7 @@ def test_extract_with_mapping_file(frozen_time, cli, pot_file):
190194
msgstr ""
191195
"Project-Id-Version: TestProject 0.1\n"
192196
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
193-
"POT-Creation-Date: {date}\n"
197+
"POT-Creation-Date: {formatted_frozen_time}\n"
194198
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
195199
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
196200
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -215,7 +219,7 @@ def test_extract_with_mapping_file(frozen_time, cli, pot_file):
215219
assert expected_content == pot_file.read_text()
216220

217221

218-
def test_extract_with_exact_file(frozen_time, cli, pot_file):
222+
def test_extract_with_exact_file(formatted_frozen_time, cli, pot_file):
219223
"""Tests that we can call extract with a particular file and only
220224
strings from that file get extracted. (Note the absence of strings from file1.py)
221225
"""
@@ -232,7 +236,6 @@ def test_extract_with_exact_file(frozen_time, cli, pot_file):
232236
'-c', 'TRANSLATORS:',
233237
'-o', pot_file, file_to_extract,
234238
]) # fmt: skip
235-
date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
236239
expected_content = fr"""# Translations template for TestProject.
237240
# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
238241
# This file is distributed under the same license as the TestProject
@@ -244,7 +247,7 @@ def test_extract_with_exact_file(frozen_time, cli, pot_file):
244247
msgstr ""
245248
"Project-Id-Version: TestProject 0.1\n"
246249
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
247-
"POT-Creation-Date: {date}\n"
250+
"POT-Creation-Date: {formatted_frozen_time}\n"
248251
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
249252
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
250253
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -263,7 +266,7 @@ def test_extract_with_exact_file(frozen_time, cli, pot_file):
263266
assert expected_content == pot_file.read_text()
264267

265268

266-
def test_init_with_output_dir(frozen_time, cli):
269+
def test_init_with_output_dir(formatted_frozen_time, cli):
267270
po_file = get_po_file_path('en_US')
268271
cli.run([
269272
'pybabel',
@@ -272,7 +275,6 @@ def test_init_with_output_dir(frozen_time, cli):
272275
'-d', os.path.join(i18n_dir),
273276
'-i', os.path.join(i18n_dir, 'messages.pot'),
274277
]) # fmt: skip
275-
date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
276278
expected_content = fr"""# English (United States) translations for TestProject.
277279
# Copyright (C) 2007 FooBar, Inc.
278280
# This file is distributed under the same license as the TestProject
@@ -284,7 +286,7 @@ def test_init_with_output_dir(frozen_time, cli):
284286
"Project-Id-Version: TestProject 0.1\n"
285287
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
286288
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
287-
"PO-Revision-Date: {date}\n"
289+
"PO-Revision-Date: {formatted_frozen_time}\n"
288290
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
289291
"Language: en_US\n"
290292
"Language-Team: en_US <LL@li.org>\n"
@@ -312,7 +314,7 @@ def test_init_with_output_dir(frozen_time, cli):
312314
assert expected_content == actual_content
313315

314316

315-
def test_init_singular_plural_forms(frozen_time, cli):
317+
def test_init_singular_plural_forms(formatted_frozen_time, cli):
316318
po_file = get_po_file_path('ja_JP')
317319
cli.run([
318320
'pybabel',
@@ -321,7 +323,6 @@ def test_init_singular_plural_forms(frozen_time, cli):
321323
'-d', os.path.join(i18n_dir),
322324
'-i', os.path.join(i18n_dir, 'messages.pot'),
323325
]) # fmt: skip
324-
date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
325326
expected_content = fr"""# Japanese (Japan) translations for TestProject.
326327
# Copyright (C) 2007 FooBar, Inc.
327328
# This file is distributed under the same license as the TestProject
@@ -333,7 +334,7 @@ def test_init_singular_plural_forms(frozen_time, cli):
333334
"Project-Id-Version: TestProject 0.1\n"
334335
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
335336
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
336-
"PO-Revision-Date: {date}\n"
337+
"PO-Revision-Date: {formatted_frozen_time}\n"
337338
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
338339
"Language: ja_JP\n"
339340
"Language-Team: ja_JP <LL@li.org>\n"
@@ -360,7 +361,7 @@ def test_init_singular_plural_forms(frozen_time, cli):
360361
assert expected_content == actual_content
361362

362363

363-
def test_init_more_than_2_plural_forms(frozen_time, cli):
364+
def test_init_more_than_2_plural_forms(formatted_frozen_time, cli):
364365
po_file = get_po_file_path('lv_LV')
365366
cli.run([
366367
'pybabel',
@@ -369,7 +370,6 @@ def test_init_more_than_2_plural_forms(frozen_time, cli):
369370
'-d', i18n_dir,
370371
'-i', os.path.join(i18n_dir, 'messages.pot'),
371372
]) # fmt: skip
372-
date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
373373
expected_content = fr"""# Latvian (Latvia) translations for TestProject.
374374
# Copyright (C) 2007 FooBar, Inc.
375375
# This file is distributed under the same license as the TestProject
@@ -381,7 +381,7 @@ def test_init_more_than_2_plural_forms(frozen_time, cli):
381381
"Project-Id-Version: TestProject 0.1\n"
382382
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
383383
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
384-
"PO-Revision-Date: {date}\n"
384+
"PO-Revision-Date: {formatted_frozen_time}\n"
385385
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
386386
"Language: lv_LV\n"
387387
"Language-Team: lv_LV <LL@li.org>\n"

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL