| 1 |
import pathlib |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
from babel.messages import frontend |
| 6 |
|
| 7 |
jinja2 = pytest.importorskip("jinja2") |
| 8 |
|
| 9 |
jinja2_data_path = pathlib.Path(__file__).parent / "jinja2_data" |
| 10 |
|
| 11 |
|
| 12 |
def test_jinja2_interop(monkeypatch, tmp_path): |
| 13 |
""" |
| 14 |
Test that babel can extract messages from Jinja2 templates. |
| 15 |
""" |
| 16 |
monkeypatch.chdir(jinja2_data_path) |
| 17 |
cli = frontend.CommandLineInterface() |
| 18 |
pot_file = tmp_path / "messages.pot" |
| 19 |
cli.run(['pybabel', 'extract', '--mapping', 'mapping.cfg', '-o', str(pot_file), '.']) |
| 20 |
assert '"Hello, %(name)s!"' in pot_file.read_text() |