-
-
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
pytest 3.3.0 immutable fixture params #2959
Comments
its neither intended, not was it a bug we simply didn't fall over because users would mutate random aliased objects that would then end up in the internals the correct way to make fixtures dynamic is something like this: def pytest_configure(config):
class DynamicFixturePlugin(object):
@pytest.fixture(scope='session', params=config.getoption('--servers'), ids=...)
def server_bin(request):
return request.param
config.pluginmanager.register(DynamicFixturePlugin(), 'server-bin-fixture') |
Ok, thanks, |
Do we still consider this |
@nicoddemus it practically is a regression, but its one i'd like to not fix since fixing it makes things worse in the internals again |
@RonnyPfannschmidt I agree, doesn't seem like something we want to actually fix, at least not in its current form where it was working by accident rather than by design. @popravich when you can please let us know if the workaround worked for you. |
I just found out about this today. Is it worth it to at least add a disclaimer somehow in the CHANGELOG? Our deployment to PROD was skipping some tests without us even noticing so I believe its something worth to comment. |
@nicoddemus, the suggested code works with a tiny fix def pytest_configure(config):
class DynamicFixturePlugin(object):
@pytest.fixture(scope='session', params=config.getoption('--servers'), ids=...)
- def server_bin(request):
+ def server_bin(self, request):
return request.param
config.pluginmanager.register(DynamicFixturePlugin(), 'server-bin-fixture') And I'm +1 to @argaen about some notes in CHANGELOG. |
@argaen and @popravich agree, thanks for the suggestion: #2980 |
Before v3.3.0 it was possible to mutate fixture parameters, since v3.3.0 params gets "frozen"
(I guess its introduced with this commit 07b2b18)
I was using this feature to setup fixture parameters based on command-line options:
So my questions:
The text was updated successfully, but these errors were encountered: