()
| 593 | |
| 594 | |
| 595 | def extract_from_snapshots(): |
| 596 | snapshots = { |
| 597 | 'messages.py': (), |
| 598 | 'fileloc.py': ('--docstrings',), |
| 599 | 'docstrings.py': ('--docstrings',), |
| 600 | 'comments.py': ('--add-comments=i18n:',), |
| 601 | 'custom_keywords.py': ('--keyword=foo', '--keyword=nfoo:1,2', |
| 602 | '--keyword=pfoo:1c,2', |
| 603 | '--keyword=npfoo:1c,2,3', '--keyword=_:1,2'), |
| 604 | 'multiple_keywords.py': ('--keyword=foo:1c,2,3', '--keyword=foo:1c,2', |
| 605 | '--keyword=foo:1,2', |
| 606 | # repeat a keyword to make sure it is extracted only once |
| 607 | '--keyword=foo', '--keyword=foo'), |
| 608 | # == Test character escaping |
| 609 | # Escape ascii and unicode: |
| 610 | 'escapes.py': ('--escape', '--add-comments='), |
| 611 | # Escape only ascii and let unicode pass through: |
| 612 | ('escapes.py', 'ascii-escapes.pot'): ('--add-comments=',), |
| 613 | } |
| 614 | |
| 615 | for filename, args in snapshots.items(): |
| 616 | if isinstance(filename, tuple): |
| 617 | filename, output_file = filename |
| 618 | output_file = DATA_DIR / output_file |
| 619 | input_file = DATA_DIR / filename |
| 620 | else: |
| 621 | input_file = DATA_DIR / filename |
| 622 | output_file = input_file.with_suffix('.pot') |
| 623 | contents = input_file.read_bytes() |
| 624 | with temp_cwd(None): |
| 625 | Path(input_file.name).write_bytes(contents) |
| 626 | assert_python_ok('-Xutf8', Test_pygettext.script, *args, |
| 627 | input_file.name) |
| 628 | yield (input_file, output_file, |
| 629 | Path('messages.pot').read_text(encoding='utf-8')) |
| 630 | |
| 631 | |
| 632 | def update_POT_snapshots(): |
no test coverage detected
searching dependent graphs…