Skip to content

Commit b427828

Browse files
committed
fixing pytest
aaaaaaaaaaaaaaaaaaaaa Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent e162662 commit b427828

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/conftest.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ def pytest_runtest_logreport(report):
174174
@pytest.fixture
175175
def test_output_dir(results_dir, request):
176176
"""Create and return a test specific directory"""
177+
if results_dir is None:
178+
return None
179+
177180
raw_data_path = Path(results_dir / request.node.name)
178181
if raw_data_path.is_dir():
179182
shutil.rmtree(raw_data_path)
@@ -198,7 +201,8 @@ def metrics(test_output_dir, request):
198201
metrics_logger.set_property(prop_name, prop_val)
199202
yield metrics_logger
200203
metrics_logger.flush()
201-
metrics_logger.store_data(test_output_dir)
204+
if test_output_dir:
205+
metrics_logger.store_data(test_output_dir)
202206

203207

204208
@pytest.fixture
@@ -407,12 +411,17 @@ def results_dir(request):
407411
408412
For example
409413
```py
410-
def test_my_file(results_dir):
414+
def test_my_file(reggsults_dir):
411415
(results_dir / "output.txt").write_text("Hello World")
412416
```
413417
will result in `defs.TEST_RESULTS_DIR`/test_my_file/output.txt.
418+
419+
Because this fixture is
414420
"""
415-
results_dir = defs.TEST_RESULTS_DIR / request.node.originalname
421+
try:
422+
results_dir = defs.TEST_RESULTS_DIR / request.node.originalname
423+
except AttributeError:
424+
return None
416425
results_dir.mkdir(parents=True, exist_ok=True)
417426
return results_dir
418427

0 commit comments

Comments
 (0)