Use hasattr instead of try/except
--HG-- branch : issue463
This commit is contained in:
parent
ac17f20d98
commit
6f81602ba2
|
@ -142,13 +142,10 @@ def pytest_cmdline_main(config):
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
try:
|
# this misspelling is common - raise a specific error to alert the user
|
||||||
# this misspelling is common - raise a specific error to alert the user
|
if hasattr(metafunc.function, 'parameterize'):
|
||||||
markers = metafunc.function.parameterize
|
|
||||||
msg = "{} has mark 'parameterize', spelling should be 'parametrize'"
|
msg = "{} has mark 'parameterize', spelling should be 'parametrize'"
|
||||||
raise ValueError(msg.format(metafunc.function.__name__))
|
raise ValueError(msg.format(metafunc.function.__name__))
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
try:
|
try:
|
||||||
markers = metafunc.function.parametrize
|
markers = metafunc.function.parametrize
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
Loading…
Reference in New Issue