Strip whitespace from markers in INI config

Resolves #2856.
This commit is contained in:
Sviatoslav Abakumov 2017-10-24 11:17:01 +03:00
parent 4cb60dac3d
commit 52aadcd7c1
3 changed files with 21 additions and 2 deletions

View File

@ -272,8 +272,9 @@ class MarkGenerator:
pass
self._markers = l = set()
for line in self._config.getini("markers"):
beginning = line.split(":", 1)
x = beginning[0].split("(", 1)[0]
marker, _ = line.split(":", 1)
marker = marker.rstrip()
x = marker.split("(", 1)[0]
l.add(x)
if name not in self._markers:
raise AttributeError("%r not a registered marker" % (name,))

1
changelog/2856.bugfix Normal file
View File

@ -0,0 +1 @@
Strip whitespace from marker names when reading them from INI config.

View File

@ -169,6 +169,23 @@ def test_markers_option(testdir):
])
def test_ini_markers_whitespace(testdir):
testdir.makeini("""
[pytest]
markers =
a1 : this is a whitespace marker
""")
testdir.makepyfile("""
import pytest
@pytest.mark.a1
def test_markers():
assert True
""")
rec = testdir.inline_run("--strict", "-m", "a1")
rec.assertoutcome(passed=1)
def test_markers_option_with_plugin_in_current_dir(testdir):
testdir.makeconftest('pytest_plugins = "flip_flop"')
testdir.makepyfile(flip_flop="""\