Skip to content

Commit 77b94a4

Browse files
Add Pytest Markers Configuration (#1849)
* Add pytest.ini with markers specified * Update conftest with automatic markers based on test path --------- Co-authored-by: Karl Higley <kmhigley@gmail.com>
1 parent 24136ef commit 77b94a4

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

pytest.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[pytest]
2+
markers =
3+
unit: mark as unit test
4+
examples: mark as example
5+
ops: mark as tesing operators
6+
loader: mark as testing the dataloader
7+
tensorflow: mark as using tensorflow
8+
torch: mark as using torch
9+
singlegpu: mark as testing single GPU
10+
multigpu: mark as testing multi-GPU

tests/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,29 @@ def report(request):
374374
return request.config.getoption("--report")
375375

376376

377+
def pytest_collection_modifyitems(items):
378+
for item in items:
379+
path = item.location[0]
380+
381+
if "/unit/" in path:
382+
item.add_marker(getattr(pytest.mark, "unit"))
383+
384+
if "/loader/" in path:
385+
item.add_marker(getattr(pytest.mark, "loader"))
386+
387+
if "/examples/" in path:
388+
item.add_marker(getattr(pytest.mark, "examples"))
389+
390+
if "/ops/" in path:
391+
item.add_marker(getattr(pytest.mark, "ops"))
392+
393+
if "test_tf_" in path:
394+
item.add_marker(getattr(pytest.mark, "tensorflow"))
395+
396+
if "test_torch_" in path:
397+
item.add_marker(getattr(pytest.mark, "torch"))
398+
399+
377400
@pytest.fixture(scope="function", autouse=True)
378401
def cleanup_dataloader():
379402
"""After each test runs. Call .stop() on any dataloaders created during the test.

0 commit comments

Comments
 (0)