-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix JinjaAdapter when passing environment instance.
- Loading branch information
Raphael Krupinski
committed
Feb 9, 2024
1 parent
571513d
commit f8c8956
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
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
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,34 @@ | ||
import pytest | ||
from jinja2 import Environment, FileSystemLoader | ||
from rybak.jinja import JinjaAdapter | ||
|
||
|
||
def test_jinja_init_keep_newlines(): | ||
env = Environment(loader=FileSystemLoader('-path-')) | ||
adapter = JinjaAdapter(env) | ||
|
||
assert adapter._env.keep_trailing_newline is True | ||
|
||
|
||
def test_jinja_init_keep_newlines_false(): | ||
env = Environment(loader=FileSystemLoader('-path-')) | ||
adapter = JinjaAdapter(env, keep_trailing_newline=False) | ||
|
||
assert adapter._env.keep_trailing_newline is False | ||
|
||
|
||
def test_jinja_loader(): | ||
loader = FileSystemLoader('-path-') | ||
adapter = JinjaAdapter(loader=loader) | ||
|
||
assert adapter._env.loader == loader | ||
|
||
|
||
def test_jinja_env_loader_error(): | ||
with pytest.raises(ValueError): | ||
JinjaAdapter(environment=Environment(), loader=FileSystemLoader('-path-')) | ||
|
||
|
||
def test_jinja_no_env_loader_error(): | ||
with pytest.raises(ValueError): | ||
JinjaAdapter() |