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):
|
||||
try:
|
||||
# this misspelling is common - raise a specific error to alert the user
|
||||
markers = metafunc.function.parameterize
|
||||
# this misspelling is common - raise a specific error to alert the user
|
||||
if hasattr(metafunc.function, 'parameterize'):
|
||||
msg = "{} has mark 'parameterize', spelling should be 'parametrize'"
|
||||
raise ValueError(msg.format(metafunc.function.__name__))
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
markers = metafunc.function.parametrize
|
||||
except AttributeError:
|
||||
|
|
Loading…
Reference in New Issue