File tree Expand file tree Collapse file tree 3 files changed +78
-11
lines changed Expand file tree Collapse file tree 3 files changed +78
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Release 0.5.0 (unreleased)
44New Features in 0.5.0
55~~~~~~~~~~~~~~~~~~~~~
66- Support for Eaton ePDU added, and can be used as a NetworkPowerPort.
7+ - Consider a combination of multiple "lg_feature" markers instead of
8+ considering only the closest marker.
79
810Bug fixes in 0.5.0
911~~~~~~~~~~~~~~~~~~
Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ def pytest_configure(config):
5353def pytest_collection_modifyitems (config , items ):
5454 """This function matches function feature flags with those found in the
5555 environment and disables the item if no match is found"""
56- have_feature = []
5756 env = config ._labgrid_env
5857
5958 if not env :
@@ -62,17 +61,16 @@ def pytest_collection_modifyitems(config, items):
6261 have_feature = env .get_features () | env .get_target_features ()
6362
6463 for item in items :
65- marker = item .get_closest_marker ("lg_feature" )
66- if not marker :
67- continue
64+ want_feature = set ()
6865
69- arg = marker .args [0 ]
70- if isinstance (arg , str ):
71- want_feature = set ([arg ])
72- elif isinstance (arg , list ):
73- want_feature = set (arg )
74- else :
75- raise Exception ("Unsupported feature argument type" )
66+ for marker in item .iter_markers ("lg_feature" ):
67+ arg = marker .args [0 ]
68+ if isinstance (arg , str ):
69+ want_feature .add (arg )
70+ elif isinstance (arg , list ):
71+ want_feature .update (arg )
72+ else :
73+ raise Exception ("Unsupported feature argument type" )
7674 missing_feature = want_feature - have_feature
7775 if missing_feature :
7876 if len (missing_feature ) == 1 :
Original file line number Diff line number Diff line change @@ -112,3 +112,70 @@ def test(env):
112112 spawn .expect (pexpect .EOF )
113113 spawn .close ()
114114 assert spawn .exitstatus == 0
115+
116+ def test_match_multi_feature_source (tmpdir ):
117+ conf = tmpdir .join ("config.yaml" )
118+ conf .write (
119+ """
120+ targets:
121+ test1:
122+ features:
123+ - test1
124+ - test2
125+ - test3
126+ drivers: {}
127+ """
128+ )
129+ test = tmpdir .join ("test.py" )
130+ test .write (
131+ """
132+ import pytest
133+
134+ pytestmark = pytest.mark.lg_feature("test1")
135+
136+ @pytest.mark.lg_feature("test2")
137+ class TestMulti:
138+ @pytest.mark.lg_feature("test3")
139+ def test(self, env):
140+ assert True
141+ """
142+ )
143+
144+ with pexpect .spawn (f'pytest --lg-env { conf } { test } ' ) as spawn :
145+ spawn .expect ("1 passed" )
146+ spawn .expect (pexpect .EOF )
147+ spawn .close ()
148+ assert spawn .exitstatus == 0
149+
150+ def test_skip_multi_feature_source (tmpdir ):
151+ conf = tmpdir .join ("config.yaml" )
152+ conf .write (
153+ """
154+ targets:
155+ test1:
156+ features:
157+ - test1
158+ - test3
159+ drivers: {}
160+ """
161+ )
162+ test = tmpdir .join ("test.py" )
163+ test .write (
164+ """
165+ import pytest
166+
167+ pytestmark = pytest.mark.lg_feature("test1")
168+
169+ @pytest.mark.lg_feature("test2")
170+ class TestMulti:
171+ @pytest.mark.lg_feature("test3")
172+ def test(self, env):
173+ assert True
174+ """
175+ )
176+
177+ with pexpect .spawn (f'pytest --lg-env { conf } { test } ' ) as spawn :
178+ spawn .expect ("1 skipped" )
179+ spawn .expect (pexpect .EOF )
180+ spawn .close ()
181+ assert spawn .exitstatus == 0
You can’t perform that action at this time.
0 commit comments