-
Notifications
You must be signed in to change notification settings - Fork 30
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
LazyFixture only resolved when used directly, but not in lists etc. #24
Comments
I'd love to see this supported as well. We have a case where we want to add some metadata about existing fixtures when they are used as part of a different fixture. The metadata doesn't make sense to include in the original fixtures because it is only relevant in the new context. The natural way to tie the original fixtures and related metadata together would be in the params of the new fixture. |
…t not in lists etc.
Another place where this shows up is parametrized tests which operate over arbitrary numbers of arguments, which is something I often use. Toy example:
Here on the third run of the test, |
I also have this issue. My use case is a single test that checks that all the methods that should raise a certain exception do, so in my parametrize I pass in the Callable as one argument and the "extra parameters" dictionary as the second. I then expand this to pass them in as keyword args to the Callable, but one of these extra parameters, for one method only, needs to use a fixture (as the exception is only thrown when all other params are valid). |
Count me also among those who consider this issue important. |
I tackled it as well, in my case I wanted to pass a dictionary with multiple fixtures. Since it was passed as a sequence I don't have the access to the fixture value within. |
This feature would be useful. But since there is no plans to release this, I am moving to |
Finding this important as well! My case, inside a dictionary: @pytest.mark.parametrize(
argnames=["args", "error"],
argvalues=[
({"filename": "1000"}, TypeError),
({"filename": pytest.lazy_fixture("filename"), "threshold": "threshold"}, TypeError),
({"filename": pytest.lazy_fixture("no_filename")}, FileNotFoundError),
({"filename": pytest.lazy_fixture("filename"), "threshold": -10}, ValueError),
({"filename": pytest.lazy_fixture("filename"), "threshold": 1}, ValueError),
({"filename": pytest.lazy_fixture("filename"), "threshold": 10}, ValueError),
]
)
def test_ibd_errors( # noqa: D103
otter_qc: OtterQC, args: dict[str, Any], error: Exception
):
with pytest.raises(error):
otter_qc.ibd(**args) |
My use case requires preparing lists of things instead of just single things one by one, please see your example adapted accordingly below.
Inside
test_func()
thesome_list
will be something like[<LazyFixture "one">, <LazyFixture "two">]
where I would have expected that this had been expanded/resolved to[1, 2]
.Is there a way to always expand /resolve in a test context no matter how wrapped or nested the
LazyFixture
is?Cheers
The text was updated successfully, but these errors were encountered: