Skip to content

Commit 447f9a2

Browse files
author
Jan Musial
committed
Mark all tests in security directory as security
Signed-off-by: Jan Musial <[email protected]>
1 parent 4690cd6 commit 447f9a2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/functional/pytest.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
22
markers =
3-
security: security objectives coverage
3+
security: security objectives coverage, do not run by default
44
long: long, do not run by default
5-
addopts = --ignore=tests/security -m "not long"
5+
addopts = -m "not long and not security"

tests/functional/tests/security/conftest.py

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
c_uint16,
1212
c_int
1313
)
14+
from pathlib import Path
1415
from tests.utils.random import RandomStringGenerator, RandomGenerator, DefaultRanges, Range
1516

1617
from pyocf.types.cache import CacheMode, MetadataLayout, PromotionPolicy
@@ -21,6 +22,17 @@
2122
sys.path.append(os.path.join(os.path.dirname(__file__), os.path.pardir))
2223

2324

25+
def pytest_collection_modifyitems(session, config, items):
26+
# This hook receives all items collected in session (not only from directory conftest is located
27+
# in). Additional path-based filtering is needed.
28+
29+
base_dir = Path(config.rootdir)
30+
for item in items:
31+
rel_path = Path(item.fspath).relative_to(base_dir)
32+
if rel_path.match("*/security/*"):
33+
item.add_marker(pytest.mark.security)
34+
35+
2436
def enum_min(enum):
2537
return list(enum)[0].value
2638

0 commit comments

Comments
 (0)