pytest 3.3.0 immutable fixture params
See original GitHub issueBefore v3.3.0 it was possible to mutate fixture parameters, since v3.3.0 params gets “frozen” (I guess its introduced with this commit 07b2b18a01a3ba12757a4eb1c0e082922f5299e5)
I was using this feature to setup fixture parameters based on command-line options:
BINS = []
@pytest.fixture(scope='session', params=BINS, ids=...)
def server_bin(request):
return request.param
@pytest.fixture(scope='session')
def run_server(server_bin):
pass # start application
def pytest_configure(config):
BINS[:] = config.getoption('--server')[:]
- Here is the real use case https://github.com/aio-libs/aioredis/blob/pyup/tests/conftest.py#L245-L254
- Here are the travis builds before and after update;
So my questions:
- Is this new behavior intended or its a bug?
- And if its intended what is new way to make dynamic parameters?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
pytest fixtures: explicit, modular, scalable
fixture management scales from simple unit to complex functional testing, allowing to parametrize fixtures and tests according to configuration and component ...
Read more >pytest: Versions - Openbase
Full version history for pytest including change logs. ... #9514: Type-annotate FixtureRequest.param as Any as a stop gap measure until 8073 ...
Read more >All You Need To Know To Start Using Fixtures In Your Pytest ...
The @pytest.fixture decorator provides an easy yet powerful way to setup and teardown resources. You can then pass these defined fixture objects ...
Read more >Welcome to Pytest-BDD's documentation! — Pytest-BDD 6.1.1 ...
Step parsed arguments conflicted with the fixtures. Now they no longer define fixture. If the fixture has to be defined by the step...
Read more >How To Make Your Pytest Tests as DRY as Bone
Furthermore, I have added the params argument to the fixture decorator. With this, you can define default values for your parameterized fixture.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@argaen and @popravich agree, thanks for the suggestion: #2980
@nicoddemus, the suggested code works with a tiny fix
And I’m +1 to @argaen about some notes in CHANGELOG.