| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,7 +110,7 @@ def test_help(cli): | |||
| 110 | 110 | assert all(command in content for command in ('init', 'update', 'compile', 'extract')) | |
| 111 | 111 | ||
| 112 | 112 | ||
| 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): | ||
| 114 | 114 | cli.run([ | |
| 115 | 115 | 'pybabel', | |
| 116 | 116 | 'extract', | |
@@ -122,7 +122,6 @@ def test_extract_with_default_mapping(frozen_time, cli, pot_file): | |||
| 122 | 122 | '-c', 'TRANSLATORS:', | |
| 123 | 123 | '-o', pot_file, 'project', | |
| 124 | 124 | ]) # fmt: skip | |
| 125 | - date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') | ||
| 126 | 125 | expected_content = fr"""# Translations template for TestProject. | |
| 127 | 126 | # Copyright (C) {time.strftime('%Y')} FooBar, Inc. | |
| 128 | 127 | # 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): | |||
| 134 | 133 | msgstr "" | |
| 135 | 134 | "Project-Id-Version: TestProject 0.1\n" | |
| 136 | 135 | "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
| 137 | - "POT-Creation-Date: {date}\n" | ||
| 136 | + "POT-Creation-Date: {formatted_frozen_time}\n" | ||
| 138 | 137 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |
| 139 | 138 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 140 | 139 | "Language-Team: LANGUAGE <LL@li.org>\n" | |
@@ -165,7 +164,13 @@ def test_extract_with_default_mapping(frozen_time, cli, pot_file): | |||
| 165 | 164 | assert expected_content == pot_file.read_text() | |
| 166 | 165 | ||
| 167 | 166 | ||
| 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): | ||
| 169 | 174 | cli.run([ | |
| 170 | 175 | 'pybabel', | |
| 171 | 176 | 'extract', | |
@@ -178,7 +183,6 @@ def test_extract_with_mapping_file(frozen_time, cli, pot_file): | |||
| 178 | 183 | '-c', 'TRANSLATORS:', | |
| 179 | 184 | '-o', pot_file, 'project', | |
| 180 | 185 | ]) # fmt: skip | |
| 181 | - date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') | ||
| 182 | 186 | expected_content = fr"""# Translations template for TestProject. | |
| 183 | 187 | # Copyright (C) {time.strftime('%Y')} FooBar, Inc. | |
| 184 | 188 | # 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): | |||
| 190 | 194 | msgstr "" | |
| 191 | 195 | "Project-Id-Version: TestProject 0.1\n" | |
| 192 | 196 | "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
| 193 | - "POT-Creation-Date: {date}\n" | ||
| 197 | + "POT-Creation-Date: {formatted_frozen_time}\n" | ||
| 194 | 198 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |
| 195 | 199 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 196 | 200 | "Language-Team: LANGUAGE <LL@li.org>\n" | |
@@ -215,7 +219,7 @@ def test_extract_with_mapping_file(frozen_time, cli, pot_file): | |||
| 215 | 219 | assert expected_content == pot_file.read_text() | |
| 216 | 220 | ||
| 217 | 221 | ||
| 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): | ||
| 219 | 223 | """Tests that we can call extract with a particular file and only | |
| 220 | 224 | strings from that file get extracted. (Note the absence of strings from file1.py) | |
| 221 | 225 | """ | |
@@ -232,7 +236,6 @@ def test_extract_with_exact_file(frozen_time, cli, pot_file): | |||
| 232 | 236 | '-c', 'TRANSLATORS:', | |
| 233 | 237 | '-o', pot_file, file_to_extract, | |
| 234 | 238 | ]) # fmt: skip | |
| 235 | - date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') | ||
| 236 | 239 | expected_content = fr"""# Translations template for TestProject. | |
| 237 | 240 | # Copyright (C) {time.strftime('%Y')} FooBar, Inc. | |
| 238 | 241 | # 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): | |||
| 244 | 247 | msgstr "" | |
| 245 | 248 | "Project-Id-Version: TestProject 0.1\n" | |
| 246 | 249 | "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
| 247 | - "POT-Creation-Date: {date}\n" | ||
| 250 | + "POT-Creation-Date: {formatted_frozen_time}\n" | ||
| 248 | 251 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | |
| 249 | 252 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 250 | 253 | "Language-Team: LANGUAGE <LL@li.org>\n" | |
@@ -263,7 +266,7 @@ def test_extract_with_exact_file(frozen_time, cli, pot_file): | |||
| 263 | 266 | assert expected_content == pot_file.read_text() | |
| 264 | 267 | ||
| 265 | 268 | ||
| 266 | - def test_init_with_output_dir(frozen_time, cli): | ||
| 269 | + def test_init_with_output_dir(formatted_frozen_time, cli): | ||
| 267 | 270 | po_file = get_po_file_path('en_US') | |
| 268 | 271 | cli.run([ | |
| 269 | 272 | 'pybabel', | |
@@ -272,7 +275,6 @@ def test_init_with_output_dir(frozen_time, cli): | |||
| 272 | 275 | '-d', os.path.join(i18n_dir), | |
| 273 | 276 | '-i', os.path.join(i18n_dir, 'messages.pot'), | |
| 274 | 277 | ]) # fmt: skip | |
| 275 | - date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') | ||
| 276 | 278 | expected_content = fr"""# English (United States) translations for TestProject. | |
| 277 | 279 | # Copyright (C) 2007 FooBar, Inc. | |
| 278 | 280 | # This file is distributed under the same license as the TestProject | |
@@ -284,7 +286,7 @@ def test_init_with_output_dir(frozen_time, cli): | |||
| 284 | 286 | "Project-Id-Version: TestProject 0.1\n" | |
| 285 | 287 | "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
| 286 | 288 | "POT-Creation-Date: 2007-04-01 15:30+0200\n" | |
| 287 | - "PO-Revision-Date: {date}\n" | ||
| 289 | + "PO-Revision-Date: {formatted_frozen_time}\n" | ||
| 288 | 290 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 289 | 291 | "Language: en_US\n" | |
| 290 | 292 | "Language-Team: en_US <LL@li.org>\n" | |
@@ -312,7 +314,7 @@ def test_init_with_output_dir(frozen_time, cli): | |||
| 312 | 314 | assert expected_content == actual_content | |
| 313 | 315 | ||
| 314 | 316 | ||
| 315 | - def test_init_singular_plural_forms(frozen_time, cli): | ||
| 317 | + def test_init_singular_plural_forms(formatted_frozen_time, cli): | ||
| 316 | 318 | po_file = get_po_file_path('ja_JP') | |
| 317 | 319 | cli.run([ | |
| 318 | 320 | 'pybabel', | |
@@ -321,7 +323,6 @@ def test_init_singular_plural_forms(frozen_time, cli): | |||
| 321 | 323 | '-d', os.path.join(i18n_dir), | |
| 322 | 324 | '-i', os.path.join(i18n_dir, 'messages.pot'), | |
| 323 | 325 | ]) # fmt: skip | |
| 324 | - date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') | ||
| 325 | 326 | expected_content = fr"""# Japanese (Japan) translations for TestProject. | |
| 326 | 327 | # Copyright (C) 2007 FooBar, Inc. | |
| 327 | 328 | # This file is distributed under the same license as the TestProject | |
@@ -333,7 +334,7 @@ def test_init_singular_plural_forms(frozen_time, cli): | |||
| 333 | 334 | "Project-Id-Version: TestProject 0.1\n" | |
| 334 | 335 | "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
| 335 | 336 | "POT-Creation-Date: 2007-04-01 15:30+0200\n" | |
| 336 | - "PO-Revision-Date: {date}\n" | ||
| 337 | + "PO-Revision-Date: {formatted_frozen_time}\n" | ||
| 337 | 338 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 338 | 339 | "Language: ja_JP\n" | |
| 339 | 340 | "Language-Team: ja_JP <LL@li.org>\n" | |
@@ -360,7 +361,7 @@ def test_init_singular_plural_forms(frozen_time, cli): | |||
| 360 | 361 | assert expected_content == actual_content | |
| 361 | 362 | ||
| 362 | 363 | ||
| 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): | ||
| 364 | 365 | po_file = get_po_file_path('lv_LV') | |
| 365 | 366 | cli.run([ | |
| 366 | 367 | 'pybabel', | |
@@ -369,7 +370,6 @@ def test_init_more_than_2_plural_forms(frozen_time, cli): | |||
| 369 | 370 | '-d', i18n_dir, | |
| 370 | 371 | '-i', os.path.join(i18n_dir, 'messages.pot'), | |
| 371 | 372 | ]) # fmt: skip | |
| 372 | - date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') | ||
| 373 | 373 | expected_content = fr"""# Latvian (Latvia) translations for TestProject. | |
| 374 | 374 | # Copyright (C) 2007 FooBar, Inc. | |
| 375 | 375 | # 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): | |||
| 381 | 381 | "Project-Id-Version: TestProject 0.1\n" | |
| 382 | 382 | "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
| 383 | 383 | "POT-Creation-Date: 2007-04-01 15:30+0200\n" | |
| 384 | - "PO-Revision-Date: {date}\n" | ||
| 384 | + "PO-Revision-Date: {formatted_frozen_time}\n" | ||
| 385 | 385 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
| 386 | 386 | "Language: lv_LV\n" | |
| 387 | 387 | "Language-Team: lv_LV <LL@li.org>\n" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments