From 6f81602ba2ecffbc80074e8fc67adc24ada974a9 Mon Sep 17 00:00:00 2001 From: Brianna Laugher Date: Sat, 21 Mar 2015 23:30:13 +0100 Subject: [PATCH] Use hasattr instead of try/except --HG-- branch : issue463 --- _pytest/python.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index e12664378..4681c6a7b 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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: