File: test_jinja2_interop.py

package info (click to toggle)
python-babel 2.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: python: 14,521; makefile: 177; javascript: 77; sh: 8
file content (20 lines) | stat: -rw-r--r-- 572 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pathlib

import pytest

from babel.messages import frontend

jinja2 = pytest.importorskip("jinja2")

jinja2_data_path = pathlib.Path(__file__).parent / "jinja2_data"


def test_jinja2_interop(monkeypatch, tmp_path):
    """
    Test that babel can extract messages from Jinja2 templates.
    """
    monkeypatch.chdir(jinja2_data_path)
    cli = frontend.CommandLineInterface()
    pot_file = tmp_path / "messages.pot"
    cli.run(['pybabel', 'extract', '--mapping', 'mapping.cfg', '-o', str(pot_file), '.'])
    assert '"Hello, %(name)s!"' in pot_file.read_text()