Skip to content

Commit

Permalink
Add Pytest Markers Configuration (NVIDIA-Merlin#1849)
Browse files Browse the repository at this point in the history
* Add pytest.ini with markers specified

* Update conftest with automatic markers based on test path

---------

Co-authored-by: Karl Higley <[email protected]>
  • Loading branch information
oliverholworthy and karlhigley authored Jul 4, 2023
1 parent 24136ef commit 77b94a4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[pytest]
markers =
unit: mark as unit test
examples: mark as example
ops: mark as tesing operators
loader: mark as testing the dataloader
tensorflow: mark as using tensorflow
torch: mark as using torch
singlegpu: mark as testing single GPU
multigpu: mark as testing multi-GPU
23 changes: 23 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,29 @@ def report(request):
return request.config.getoption("--report")


def pytest_collection_modifyitems(items):
for item in items:
path = item.location[0]

if "/unit/" in path:
item.add_marker(getattr(pytest.mark, "unit"))

if "/loader/" in path:
item.add_marker(getattr(pytest.mark, "loader"))

if "/examples/" in path:
item.add_marker(getattr(pytest.mark, "examples"))

if "/ops/" in path:
item.add_marker(getattr(pytest.mark, "ops"))

if "test_tf_" in path:
item.add_marker(getattr(pytest.mark, "tensorflow"))

if "test_torch_" in path:
item.add_marker(getattr(pytest.mark, "torch"))


@pytest.fixture(scope="function", autouse=True)
def cleanup_dataloader():
"""After each test runs. Call .stop() on any dataloaders created during the test.
Expand Down

0 comments on commit 77b94a4

Please sign in to comment.