-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
metafunc.parametrize(..., scope="session") fails when mixed with other parametrizations #3542
Comments
GitMate.io thinks possibly related issues are #634 (metafunc.parametrize overwrites scope), #519 (fixture scope is ignored when using metafunc.parametrize()), #570 (indirect=True in parametrize breaks fixture scopes), #244 (parametrize fails when values are unhashable), and #1111 (pytest.mark.parametrize fails with lambdas). |
that looks like a bug note that you can use fun workaround since you already know your parameters,
might do (untested) |
Thank you Ronny. I know the "workaround" very well. |
@kamichal i see - in that case - there is a deeper underlying issue that i wont be investigating in near future - i have no idea if any of the other core devs has other plans |
I came across the same bug, I think... This behavior can be demonstrated very vividly with
Workaround@kamichal For me, the workaround with Just define a real fixture with the same name (in the example below def pytest_addoption(parser):
parser.addoption("--my_parser_option")
def pytest_generate_tests(metafunc):
if "my_fixture" in metafunc.fixturenames:
metafunc.parametrize("my_fixture", metafunc.config.getoption("my_parser_option"), scope="session", indirect=True)
@pytest.fixture(scope="session")
def my_fixture(request):
return request.param
def test_fixture(my_fixture):
assert my_fixture == "world" Then you can call it with Regards |
thanks for providing the workaround, as its limited to freestanding parameterization |
There seems to be a bug in pytest where metafunc.parametrize breaks fixture scope. By creating a fixture and parameterizing it indirectly scope can be maintained
There seems to be a bug in pytest where metafunc.parametrize breaks fixture scope. By creating a fixture and parameterizing it indirectly scope can be maintained
Implement workaround for pytest issue [#3542](pytest-dev/pytest#3542) There seems to be a bug in pytest where metafunc.parametrize breaks fixture scope. By creating a fixture and parameterizing it indirectly scope can be maintained
Worked perfectly in my case. Thanks for the workaround. |
I'm sorry to be nagging, but is this something that is going to be addressed someday? Is this confirmed as a bug? |
As usual with open source projects, it will be addressed once someone feels like working on it (or someone pays someone to work on it).
@RonnyPfannschmidt (a pytest core maintainer) said "that looks like a bug" above. |
Both, python 2.7.13 and 3.5.3, pytest 3.6.1, no additional pytest plugins.
And the simplest reproduction:
Gives such an result:
Setting
indirect=True
in themetafunc.parametrize
call fixes that problem, but there is no information that it's required for larger scopes to work properly. There is only an advice to do so, but...The text was updated successfully, but these errors were encountered: