merge pfctdayelise/issue463
This commit is contained in:
commit
a7d2a82caa
|
@ -60,6 +60,8 @@
|
||||||
|
|
||||||
- allow to override parametrized fixtures with non-parametrized ones and vice versa (bubenkoff).
|
- allow to override parametrized fixtures with non-parametrized ones and vice versa (bubenkoff).
|
||||||
|
|
||||||
|
- fix issue463: raise specific error for 'parameterize' misspelling (pfctdayelise).
|
||||||
|
|
||||||
2.6.4
|
2.6.4
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
""" generic mechanism for marking and selecting python functions. """
|
""" generic mechanism for marking and selecting python functions. """
|
||||||
import py
|
import py
|
||||||
|
|
||||||
|
class MarkerError(Exception):
|
||||||
|
"""
|
||||||
|
Error in use of a pytest marker/attribute.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def pytest_namespace():
|
def pytest_namespace():
|
||||||
return {'mark': MarkGenerator()}
|
return {'mark': MarkGenerator()}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import py
|
||||||
import inspect
|
import inspect
|
||||||
import sys
|
import sys
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.mark import MarkDecorator
|
from _pytest.mark import MarkDecorator, MarkerError
|
||||||
from py._code.code import TerminalRepr
|
from py._code.code import TerminalRepr
|
||||||
|
|
||||||
import _pytest
|
import _pytest
|
||||||
|
@ -142,6 +142,10 @@ def pytest_cmdline_main(config):
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
|
# this misspelling is common - raise a specific error to alert the user
|
||||||
|
if hasattr(metafunc.function, 'parameterize'):
|
||||||
|
msg = "{0} has 'parameterize', spelling should be 'parametrize'"
|
||||||
|
raise MarkerError(msg.format(metafunc.function.__name__))
|
||||||
try:
|
try:
|
||||||
markers = metafunc.function.parametrize
|
markers = metafunc.function.parametrize
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -692,6 +692,21 @@ class TestMetafuncFunctional:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=4)
|
reprec.assertoutcome(passed=4)
|
||||||
|
|
||||||
|
@pytest.mark.issue463
|
||||||
|
def test_parameterize_misspelling(self, testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.parameterize("x", range(2))
|
||||||
|
def test_foo(x):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run('--collectonly')
|
||||||
|
failures = reprec.getfailures()
|
||||||
|
assert len(failures) == 1
|
||||||
|
expectederror = "MarkerError: test_foo has 'parameterize', spelling should be 'parametrize'"
|
||||||
|
assert expectederror in failures[0].longrepr.reprcrash.message
|
||||||
|
|
||||||
|
|
||||||
class TestMarkersWithParametrization:
|
class TestMarkersWithParametrization:
|
||||||
pytestmark = pytest.mark.issue308
|
pytestmark = pytest.mark.issue308
|
||||||
|
|
Loading…
Reference in New Issue