@@ -171,21 +171,8 @@ def pytest_runtest_logreport(report):
171
171
METRICS .flush ()
172
172
173
173
174
- @pytest .fixture
175
- def test_output_dir (results_dir , request ):
176
- """Create and return a test specific directory"""
177
- if results_dir is None :
178
- return None
179
-
180
- raw_data_path = Path (results_dir / request .node .name )
181
- if raw_data_path .is_dir ():
182
- shutil .rmtree (raw_data_path )
183
- raw_data_path .mkdir (parents = True , exist_ok = True )
184
- return raw_data_path
185
-
186
-
187
174
@pytest .fixture ()
188
- def metrics (test_output_dir , request ):
175
+ def metrics (results_dir , request ):
189
176
"""Fixture to pass the metrics scope
190
177
191
178
We use a fixture instead of the @metrics_scope decorator as that conflicts
@@ -201,8 +188,8 @@ def metrics(test_output_dir, request):
201
188
metrics_logger .set_property (prop_name , prop_val )
202
189
yield metrics_logger
203
190
metrics_logger .flush ()
204
- if test_output_dir :
205
- metrics_logger .store_data (test_output_dir )
191
+ if results_dir :
192
+ metrics_logger .store_data (results_dir )
206
193
207
194
208
195
@pytest .fixture
@@ -406,21 +393,27 @@ def results_dir(request):
406
393
"""
407
394
Fixture yielding the path to a directory into which the test can dump its results
408
395
409
- Directories are unique per test, and named after the test name. Everything the tests puts
410
- into its directory will to be uploaded to S3. Directory will be placed inside defs.TEST_RESULTS_DIR.
396
+ Directories are unique per test, and their names include test name and test parameters.
397
+ Everything the tests puts into its directory will to be uploaded to S3.
398
+ Directory will be placed inside defs.TEST_RESULTS_DIR.
411
399
412
400
For example
413
401
```py
414
- def test_my_file(reggsults_dir):
402
+ @pytest.mark.parametrize("p", ["a", "b"])
403
+ def test_my_file(p, results_dir):
415
404
(results_dir / "output.txt").write_text("Hello World")
416
405
```
417
- will result in `defs.TEST_RESULTS_DIR`/test_my_file/output.txt.
406
+ will result in:
407
+ - `defs.TEST_RESULTS_DIR`/test_my_file/test_my_file[a]/output.txt.
408
+ - `defs.TEST_RESULTS_DIR`/test_my_file/test_my_file[b]/output.txt.
418
409
419
410
When this fixture is called with DoctestItem as a request.node
420
411
during doc tests, it will return None.
421
412
"""
422
413
try :
423
- results_dir = defs .TEST_RESULTS_DIR / request .node .originalname
414
+ results_dir = (
415
+ defs .TEST_RESULTS_DIR / request .node .originalname / request .node .name
416
+ )
424
417
except AttributeError :
425
418
return None
426
419
results_dir .mkdir (parents = True , exist_ok = True )
0 commit comments