|
4 | 4 | import re |
5 | 5 | import sys |
6 | 6 | import unittest |
| 7 | +from test.test_decimal import skip_expected |
7 | 8 | from textwrap import dedent |
8 | 9 | from pathlib import Path |
9 | 10 |
|
|
18 | 19 |
|
19 | 20 |
|
20 | 21 | with imports_under_tool("i18n"): |
21 | | - from pygettext import parse_spec |
| 22 | + from pygettext import parse_spec, normalize, make_escapes |
22 | 23 |
|
23 | 24 |
|
24 | 25 | def normalize_POT_file(pot): |
@@ -516,6 +517,42 @@ def test_parse_keyword_spec(self): |
516 | 517 | parse_spec(spec) |
517 | 518 | self.assertEqual(str(cm.exception), message) |
518 | 519 |
|
| 520 | + def test_normalize_multiline(self): |
| 521 | + # required to set up normalize |
| 522 | + class NormOptions: |
| 523 | + width = 78 |
| 524 | + make_escapes(True) |
| 525 | + |
| 526 | + s = 'multi-line\n translation' |
| 527 | + s_expected = '""\n"multi-line\\n"\n" translation"' |
| 528 | + |
| 529 | + data = normalize(s, 'UTF-8', NormOptions) |
| 530 | + self.assertEqual(s_expected, data) |
| 531 | + |
| 532 | + def test_normalize_wrap(self): |
| 533 | + # required to set up normalize |
| 534 | + class NormOptions: |
| 535 | + width = 30 |
| 536 | + make_escapes(True) |
| 537 | + |
| 538 | + s = 'this string should be wrapped to 30 chars' |
| 539 | + s_expected = '""\n"this string should be wrapped "\n"to 30 chars"' |
| 540 | + |
| 541 | + data = normalize(s, 'UTF-8', NormOptions) |
| 542 | + self.assertEqual(s_expected, data) |
| 543 | + |
| 544 | + def test_normalize_nostr(self): |
| 545 | + # required to set up normalize |
| 546 | + class NormOptions: |
| 547 | + width = 78 |
| 548 | + make_escapes(True) |
| 549 | + |
| 550 | + s = '' |
| 551 | + s_expected = '""' |
| 552 | + |
| 553 | + data = normalize(s, 'UTF-8', NormOptions) |
| 554 | + self.assertEqual(s_expected, data) |
| 555 | + |
519 | 556 |
|
520 | 557 | def extract_from_snapshots(): |
521 | 558 | snapshots = { |
|
0 commit comments