@@ -49,6 +49,7 @@ fixture_name = lambda_fixture(lambda: asyncio.sleep(0, 'expression'), async_=Tru
49
49
# Request fixtures by name
50
50
fixture_name = lambda_fixture(' other_fixture' )
51
51
fixture_name = lambda_fixture(' other_fixture' , ' another_fixture' , ' cant_believe_its_not_fixture' )
52
+ ren, ame, it = lambda_fixture(' other_fixture' , ' another_fixture' , ' cant_believe_its_not_fixture' )
52
53
53
54
# Reference `self` inside a class
54
55
class TestContext :
@@ -59,6 +60,8 @@ fixture_name = lambda_fixture(params=['a', 'b'])
59
60
fixture_name = lambda_fixture(params = [' a' , ' b' ], ids = [' A!' , ' B!' ])
60
61
fixture_name = lambda_fixture(params = [pytest.param(' a' , id = ' A!' ),
61
62
pytest.param(' b' , id = ' B!' )])
63
+ alpha, omega = lambda_fixture(params = [pytest.param(' start' , ' end' , id = ' uno' ),
64
+ pytest.param(' born' , ' dead' , id = ' dos' )])
62
65
63
66
# Use literal value (not lazily evaluated)
64
67
fixture_name = static_fixture(42 )
@@ -125,6 +128,21 @@ def test_my_identity(who_i_am):
125
128
assert who_i_am == (' Jason' , ' Bourne' )
126
129
```
127
130
131
+ Destructuring assignment is also supported, allowing multiple fixtures to be renamed in one statement:
132
+ ``` python
133
+ # test_the_bourne_identity.py
134
+
135
+ from pytest_lambda import lambda_fixture, static_fixture
136
+
137
+ agent_first = static_fixture(' Jason' )
138
+ agent_last = static_fixture(' Bourne' )
139
+ first, last = lambda_fixture(' agent_first' , ' agent_last' )
140
+
141
+ def test_my_identity (first , last ):
142
+ assert first == ' Jason'
143
+ assert last == ' Bourne'
144
+ ```
145
+
128
146
129
147
#### Annotating aliased fixtures
130
148
@@ -147,6 +165,44 @@ def test_my_caddy(car):
147
165
```
148
166
149
167
168
+ ### Parametrizing
169
+
170
+ Tests can be parametrized with ` lambda_fixture ` 's ` params ` kwarg
171
+ ``` python
172
+ # test_number_5.py
173
+
174
+ from pytest_lambda import lambda_fixture
175
+
176
+ lady = lambda_fixture(params = [
177
+ ' Monica' , ' Erica' , ' Rita' , ' Tina' , ' Sandra' , ' Mary' , ' Jessica'
178
+ ])
179
+
180
+ def test_your_man (lady ):
181
+ assert lady[:0 ] in ' my life'
182
+ ```
183
+
184
+ Destructuring assignment of a parametrized lambda fixture is also supported
185
+ ``` python
186
+ # test_number_5.py
187
+
188
+ import pytest
189
+ from pytest_lambda import lambda_fixture
190
+
191
+ lady, where = lambda_fixture(params = [
192
+ pytest.param(' Monica' , ' in my life' ),
193
+ pytest.param(' Erica' , ' by my side' ),
194
+ pytest.param(' Rita' , ' is all I need' ),
195
+ pytest.param(' Tina' , ' is what I see' ),
196
+ pytest.param(' Sandra' , ' in the sun' ),
197
+ pytest.param(' Mary' , ' all night long' ),
198
+ pytest.param(' Jessica' , ' here I am' ),
199
+ ])
200
+
201
+ def test_your_man (lady , where ):
202
+ assert lady[:0 ] in where
203
+ ```
204
+
205
+
150
206
### Declaring abstract things
151
207
152
208
` not_implemented_fixture ` is perfect for labeling abstract parameter fixtures of test mixins
0 commit comments