-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional test coverage for async rendering of native type templates #1807
base: main
Are you sure you want to change the base?
Additional test coverage for async rendering of native type templates #1807
Conversation
This reverts commit 2903565.
…on case Adds additional test coverage for pallets#1511
This reverts commit 84c1836.
dcee833
to
78549cb
Compare
tests/test_nativetypes.py
Outdated
assert isinstance(result, str) | ||
assert result == "not bad" | ||
|
||
asyncio.run(async_render()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should use
def _asyncio_run(async_fn, *args):
return asyncio.run(async_fn(*args))
@pytest.fixture(params=[_asyncio_run, trio.run], ids=["asyncio", "trio"])
def run_async_fn(request):
return request.param
def test_string_concatenation(async_native_env, run_async_fn):
async def async_render():
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"
run_async_fun(async_render)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That suggested run_async_fn
fixture is used in two locations at the moment (in the main
branch of the Jinja test suite, that is) - perhaps it'd make sense to promote it to be a shared conftest.py
fixture?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That suggested
run_async_fn
fixture is used in two locations at the moment (in themain
branch of the Jinja test suite, that is) - perhaps it'd make sense to promote it to be a sharedconftest.py
fixture?
I've pushed a few changes that make that suggestion: re-using a single definition of a run_async_fn
fixture from conftest.py
.
…tion for further re-use.
Relates-to commit 67962f1.
Checklist:
Add or update relevant docs, in the docs folder and in code.CHANGES.rst
summarizing the change and linking to the issue.Add.. versionchanged::
entries in any relevant code docs.pre-commit
hooks and fix any issues.pytest
and, no tests failed.tox
PYTHONPATH=src pytest tests/test_nativetypes.py