Handle marks without description
This commit is contained in:
		
							parent
							
								
									8df7ed12c1
								
							
						
					
					
						commit
						5e71ffab87
					
				|  | @ -119,7 +119,9 @@ def pytest_cmdline_main(config): | ||||||
|         config._do_configure() |         config._do_configure() | ||||||
|         tw = _pytest.config.create_terminal_writer(config) |         tw = _pytest.config.create_terminal_writer(config) | ||||||
|         for line in config.getini("markers"): |         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.write("@pytest.mark.%s:" % name, bold=True) | ||||||
|             tw.line(rest) |             tw.line(rest) | ||||||
|             tw.line() |             tw.line() | ||||||
|  | @ -272,7 +274,7 @@ class MarkGenerator: | ||||||
|             pass |             pass | ||||||
|         self._markers = values = set() |         self._markers = values = set() | ||||||
|         for line in self._config.getini("markers"): |         for line in self._config.getini("markers"): | ||||||
|             marker, _ = line.split(":", 1) |             marker = line.split(":", 1)[0] | ||||||
|             marker = marker.rstrip() |             marker = marker.rstrip() | ||||||
|             x = marker.split("(", 1)[0] |             x = marker.split("(", 1)[0] | ||||||
|             values.add(x) |             values.add(x) | ||||||
|  |  | ||||||
|  | @ -0,0 +1 @@ | ||||||
|  | Handle marks without description | ||||||
|  | @ -161,11 +161,13 @@ def test_markers_option(testdir): | ||||||
|         markers = |         markers = | ||||||
|             a1: this is a webtest marker |             a1: this is a webtest marker | ||||||
|             a1some: another marker |             a1some: another marker | ||||||
|  |             nodescription | ||||||
|     """) |     """) | ||||||
|     result = testdir.runpytest("--markers", ) |     result = testdir.runpytest("--markers", ) | ||||||
|     result.stdout.fnmatch_lines([ |     result.stdout.fnmatch_lines([ | ||||||
|         "*a1*this is a webtest*", |         "*a1*this is a webtest*", | ||||||
|         "*a1some*another marker", |         "*a1some*another marker", | ||||||
|  |         "*nodescription*", | ||||||
|     ]) |     ]) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -186,6 +188,21 @@ def test_ini_markers_whitespace(testdir): | ||||||
|     rec.assertoutcome(passed=1) |     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): | def test_markers_option_with_plugin_in_current_dir(testdir): | ||||||
|     testdir.makeconftest('pytest_plugins = "flip_flop"') |     testdir.makeconftest('pytest_plugins = "flip_flop"') | ||||||
|     testdir.makepyfile(flip_flop="""\ |     testdir.makepyfile(flip_flop="""\ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue