Skip to content

Commit 64c2d10

Browse files
committed
feat: add cpu-gpu markers for tests
1 parent d9f6f1e commit 64c2d10

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,9 @@ inline-quotes = "double"
158158

159159
[tool.ruff.lint.flake8-tidy-imports]
160160
ban-relative-imports = "all"
161+
162+
[tool.pytest.ini_options]
163+
markers = [
164+
"cpu: marks tests as CPU test (deselect with '-m \"not cpu\"')",
165+
"gpu: marks tests as GPU test (deselect with '-m \"not gpu\"')",
166+
]

tests/test_rdma_parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def mock_available_devices() -> list[str]:
1717
return ["mlx5_0", "mlx5_1", "mlx4_0", "mlx4_1"]
1818

1919

20+
@pytest.mark.cpu
2021
def test_detect_ibv_list():
2122
"""Test detection of _ibv_get_device_list function"""
2223
# Skip this test if no real infiniband devices exist
@@ -29,6 +30,7 @@ def test_detect_ibv_list():
2930
assert isinstance(devices, list)
3031

3132

33+
@pytest.mark.cpu
3234
def test_parse_max_hcas_limit():
3335
"""Test maximum HCA quantity limit"""
3436
# Create mock data with more than 32 devices
@@ -38,6 +40,7 @@ def test_parse_max_hcas_limit():
3840
assert result == many_devices[:32]
3941

4042

43+
@pytest.mark.cpu
4144
def test_get_rdma_devices_no_env_vars(mock_available_devices: list[str]):
4245
"""Test _get_rdma_devices with no environment variables"""
4346
with (
@@ -48,6 +51,7 @@ def test_get_rdma_devices_no_env_vars(mock_available_devices: list[str]):
4851
assert sorted(devices) == sorted(mock_available_devices)
4952

5053

54+
@pytest.mark.cpu
5155
@pytest.mark.parametrize(
5256
"input_value,expected",
5357
[
@@ -70,6 +74,7 @@ def test_parse_basic_cases(
7074
assert result == expected
7175

7276

77+
@pytest.mark.cpu
7378
@pytest.mark.parametrize(
7479
"input_value,expected",
7580
[
@@ -100,6 +105,7 @@ def test_parse_various_patterns(
100105
assert result == expected
101106

102107

108+
@pytest.mark.cpu
103109
@pytest.mark.parametrize(
104110
"input_value,expected_result,expected_warning",
105111
[
@@ -127,6 +133,7 @@ def test_parse_exact_match_with_nonexistent_device(
127133
mock_logger.warning.assert_called_once_with(expected_warning)
128134

129135

136+
@pytest.mark.cpu
130137
@pytest.mark.parametrize(
131138
"env_var_name,env_var_value,expected_devices",
132139
[
@@ -154,6 +161,7 @@ def test_get_rdma_devices_with_env_vars(
154161
assert sorted(devices) == sorted(expected_devices)
155162

156163

164+
@pytest.mark.cpu
157165
@pytest.mark.parametrize(
158166
"local_rank,gpu_count,expected_device",
159167
[
@@ -171,6 +179,7 @@ def test_get_my_rdma_device_basic(local_rank: int, gpu_count: int, expected_devi
171179
assert device == expected_device
172180

173181

182+
@pytest.mark.cpu
174183
@pytest.mark.parametrize(
175184
"local_rank,gpu_count,devices,error",
176185
[

0 commit comments

Comments
 (0)