Fixtures without name matching magic
I've been happily using pytest for several projects for the past few years. There's one part about pytest that I still struggle to get behind: The way that fixtures magically match argument names to fixtures -- and apparently [I'm not alone in this feeling](https://mail.python.org/pipermail/numpy-discussion/2018-August/078560.html). I would much rather declare dependencies explicitly in some way using code. I know this would be more verbose, but that's a tradeoff I'm happy to make. Is it possible to do this in some way with pytest today? If not, would you be open to adding an *optional* feature for this? I was thinking perhaps something like the following, using an example adapted from [the docs](https://docs.pytest.org/en/latest/fixture.html): ```python import pytest @pytest.fixture def smtp_connection(): import smtplib return smtplib.SMTP("smtp.gmail.com", 587, timeout=5) @pytest.use_fixture(smtp_connection) def test_ehlo(connection): response, msg = connection.ehlo() assert response == 250 assert 0 # for demo purposes ```
Posted by shoyer on Aug 19, 2018, 7:44 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Fixtures without name matching magic
I've been happily using pytest for several projects for the past few years. There's one part about pytest that I still struggle to get behind: The way that fixtures magically match argument names to fixtures -- and apparently [I'm not alone in this feeling](https://mail.python.org/pipermail/numpy-discussion/2018-August/078560.html). I would much rather declare dependencies explicitly in some way using code. I know this would be more verbose, but that's a tradeoff I'm happy to make. Is it possible to do this in some way with pytest today? If not, would you be open to adding an *optional* feature for this? I was thinking perhaps something like the following, using an example adapted from [the docs](https://docs.pytest.org/en/latest/fixture.html): ```python import pytest @pytest.fixture def smtp_connection(): import smtplib return smtplib.SMTP("smtp.gmail.com", 587, timeout=5) @pytest.use_fixture(smtp_connection) def test_ehlo(connection): response, msg = connection.ehlo() assert response == 250 assert 0 # for demo purposes ```
Comments (0)
No comments yet. Start the discussion.