Skip to content

Commit

Permalink
Test coverage: add asynchronous native-environment string concatenati…
Browse files Browse the repository at this point in the history
…on case

Adds additional test coverage for #1511
  • Loading branch information
jayaddison committed Feb 18, 2023
1 parent 84c1836 commit 9b4e4d1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_nativetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def env():
return NativeEnvironment()


@pytest.fixture
def async_native_env():
return NativeEnvironment(enable_async=True)


def test_is_defined_native_return(env):
t = env.from_string("{{ missing is defined }}")
assert not t.render()
Expand Down Expand Up @@ -122,6 +127,16 @@ def test_string_top_level(env):
assert result == "Jinja"


@pytest.mark.asyncio
async def test_string_concatenation(async_native_env):
t = async_native_env.from_string(
"{%- macro x(y) -%}{{ y }}{%- endmacro -%}{{- x('not') }} {{ x('bad') -}}"
)
result = await t.render_async()
assert isinstance(result, str)
assert result == "not bad"


def test_tuple_of_variable_strings(env):
t = env.from_string("'{{ a }}', 'data', '{{ b }}', b'{{ c }}'")
result = t.render(a=1, b=2, c="bytes")
Expand Down

0 comments on commit 9b4e4d1

Please sign in to comment.