Use hasattr instead of try/except

--HG--
branch : issue463
This commit is contained in:
Brianna Laugher 2015-03-21 23:30:13 +01:00
parent ac17f20d98
commit 6f81602ba2
1 changed files with 2 additions and 5 deletions

View File

@ -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: