DM-55493: Import pytest unconditionally in fastapi_safir_app conftest - #354
Closed
jonathansick wants to merge 1 commit into
Closed
jonathansick wants to merge 1 commit into
jonathansick wants to merge 1 commit into
Conversation
The pytest import was inside a UWS-only Jinja conditional, but pytest_addoption, pytest.FixtureRequest, and the data fixture added in 9f67f2b use pytest in every flavor. A freshly generated non-UWS app therefore failed at test collection with NameError. The UWS rendering is unchanged; only the non-UWS example gains the import.
Member
|
Just FYI, this is also fixed in #350, which is waiting on a code review. Apologies for missing that; I didn't generate and test a package after making the previous change. (We really should do that as part of the test suite. I keep thinking about it and then not finding the time to do so.) |
rra
approved these changes
Jul 28, 2026
Member
Author
|
My maintenance bot picked these up when I was doing upgrades in my apps, so no worries. I'll close this one and we can just go ahead and merge #350, which is where we want to go anyways. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
fastapi_safir_app/{{cookiecutter.name}}/tests/conftest.pythe pytestimport sits inside a UWS-only Jinja conditional:
Since 9f67f2b, though,
pytestis used in every flavor —pytest_addoption(parser: pytest.Parser),@pytest.fixture def data(...),and
pytest.FixtureRequest. The committed non-UWS example shows theresult:
example/tests/conftest.pycallspytest.Parserand@pytest.fixturewith noimport pytestanywhere in the file.A freshly generated non-UWS app fails at collection:
This moves the import out of the conditional.
Validation
sconsre-rendered the examples. The diff is exactly what it should be:example/tests/conftest.pygainsimport pytest, andexample-uws/tests/conftest.pyis unchanged — the UWS renderingstays byte-identical.
templatekit check(with the twotechnote.tomlignores CI uses)passes:
✅ Passed!References
Found while scanning template changes for the lsst-sqre maintenance
catalog. Ticket: DM-55493.
Companion PR: #353 fixes the sibling problem in
square_pypi_package(conftest imports safir, but the dev extra doesn't include it). The two
are independent.