-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic interoperability test for Jinja2 extraction
- Loading branch information
Showing
5 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% trans %}Hello, {{ name }}!{% endtrans %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[jinja2: *.html] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters