Skip to content

Commit 717f67b

Browse files
committed
testing aaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaa Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent 3719b26 commit 717f67b

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

tests/conftest.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,8 @@ def pytest_runtest_logreport(report):
171171
METRICS.flush()
172172

173173

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-
187174
@pytest.fixture()
188-
def metrics(test_output_dir, request):
175+
def metrics(results_dir, request):
189176
"""Fixture to pass the metrics scope
190177
191178
We use a fixture instead of the @metrics_scope decorator as that conflicts
@@ -201,8 +188,8 @@ def metrics(test_output_dir, request):
201188
metrics_logger.set_property(prop_name, prop_val)
202189
yield metrics_logger
203190
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)
206193

207194

208195
@pytest.fixture
@@ -406,21 +393,27 @@ def results_dir(request):
406393
"""
407394
Fixture yielding the path to a directory into which the test can dump its results
408395
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.
411399
412400
For example
413401
```py
414-
def test_my_file(reggsults_dir):
402+
@pytest.mark.parametrize("p", ["a", "b"])
403+
def test_my_file(p, results_dir):
415404
(results_dir / "output.txt").write_text("Hello World")
416405
```
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.
418409
419410
When this fixture is called with DoctestItem as a request.node
420411
during doc tests, it will return None.
421412
"""
422413
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+
)
424417
except AttributeError:
425418
return None
426419
results_dir.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)