File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -272,8 +272,9 @@ def _check(self, name):
272272 pass
273273 self ._markers = l = set ()
274274 for line in self ._config .getini ("markers" ):
275- beginning = line .split (":" , 1 )
276- x = beginning [0 ].split ("(" , 1 )[0 ]
275+ marker , _ = line .split (":" , 1 )
276+ marker = marker .rstrip ()
277+ x = marker .split ("(" , 1 )[0 ]
277278 l .add (x )
278279 if name not in self ._markers :
279280 raise AttributeError ("%r not a registered marker" % (name ,))
Original file line number Diff line number Diff line change 1+ Strip whitespace from marker names when reading them from INI config.
Original file line number Diff line number Diff line change @@ -169,6 +169,23 @@ def test_markers_option(testdir):
169169 ])
170170
171171
172+ def test_ini_markers_whitespace (testdir ):
173+ testdir .makeini ("""
174+ [pytest]
175+ markers =
176+ a1 : this is a whitespace marker
177+ """ )
178+ testdir .makepyfile ("""
179+ import pytest
180+
181+ @pytest.mark.a1
182+ def test_markers():
183+ assert True
184+ """ )
185+ rec = testdir .inline_run ("--strict" , "-m" , "a1" )
186+ rec .assertoutcome (passed = 1 )
187+
188+
172189def test_markers_option_with_plugin_in_current_dir (testdir ):
173190 testdir .makeconftest ('pytest_plugins = "flip_flop"' )
174191 testdir .makepyfile (flip_flop = """\
You can’t perform that action at this time.
0 commit comments