Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def pytest_cmdline_main(config):
config._do_configure()
tw = _pytest.config.create_terminal_writer(config)
for line in config.getini("markers"):
name, rest = line.split(":", 1)
parts = line.split(":", 1)
name = parts[0]
rest = parts[1] if len(parts) == 2 else ''
tw.write("@pytest.mark.%s:" % name, bold=True)
tw.line(rest)
tw.line()
Expand Down Expand Up @@ -272,7 +274,7 @@ def _check(self, name):
pass
self._markers = values = set()
for line in self._config.getini("markers"):
marker, _ = line.split(":", 1)
marker = line.split(":", 1)[0]
marker = marker.rstrip()
x = marker.split("(", 1)[0]
values.add(x)
Expand Down
1 change: 1 addition & 0 deletions changelog/2942.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle marks without description in ``pytest.ini``.
17 changes: 17 additions & 0 deletions testing/test_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ def test_markers_option(testdir):
markers =
a1: this is a webtest marker
a1some: another marker
nodescription
""")
result = testdir.runpytest("--markers", )
result.stdout.fnmatch_lines([
"*a1*this is a webtest*",
"*a1some*another marker",
"*nodescription*",
])


Expand All @@ -186,6 +188,21 @@ def test_markers():
rec.assertoutcome(passed=1)


def test_marker_without_description(testdir):
testdir.makefile(".cfg", setup="""
[tool:pytest]
markers=slow
""")
testdir.makeconftest("""
import pytest
pytest.mark.xfail('FAIL')
""")
ftdir = testdir.mkdir("ft1_dummy")
testdir.tmpdir.join("conftest.py").move(ftdir.join("conftest.py"))
rec = testdir.runpytest_subprocess("--strict")
rec.assert_outcomes()


def test_markers_option_with_plugin_in_current_dir(testdir):
testdir.makeconftest('pytest_plugins = "flip_flop"')
testdir.makepyfile(flip_flop="""\
Expand Down