File tree 2 files changed +13
-8
lines changed 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -160,10 +160,13 @@ def pytest_cmdline_main(config):
160
160
161
161
162
162
def pytest_generate_tests (metafunc ):
163
- # this misspelling is common - raise a specific error to alert the user
164
- if hasattr (metafunc .function , 'parameterize' ):
165
- msg = "{0} has 'parameterize', spelling should be 'parametrize'"
166
- raise MarkerError (msg .format (metafunc .function .__name__ ))
163
+ # those alternative spellings are common - raise a specific error to alert
164
+ # the user
165
+ alt_spellings = ['parameterize' , 'parametrise' , 'parameterise' ]
166
+ for attr in alt_spellings :
167
+ if hasattr (metafunc .function , attr ):
168
+ msg = "{0} has '{1}', spelling should be 'parametrize'"
169
+ raise MarkerError (msg .format (metafunc .function .__name__ , attr ))
167
170
try :
168
171
markers = metafunc .function .parametrize
169
172
except AttributeError :
Original file line number Diff line number Diff line change @@ -683,18 +683,20 @@ def test_foo(x):
683
683
reprec .assert_outcomes (passed = 4 )
684
684
685
685
@pytest .mark .issue463
686
- def test_parameterize_misspelling (self , testdir ):
686
+ @pytest .mark .parametrize ('attr' , ['parametrise' , 'parameterize' ,
687
+ 'parameterise' ])
688
+ def test_parametrize_misspelling (self , testdir , attr ):
687
689
testdir .makepyfile ("""
688
690
import pytest
689
691
690
- @pytest.mark.parameterize ("x", range(2))
692
+ @pytest.mark.{0} ("x", range(2))
691
693
def test_foo(x):
692
694
pass
693
- """ )
695
+ """ . format ( attr ) )
694
696
reprec = testdir .inline_run ('--collectonly' )
695
697
failures = reprec .getfailures ()
696
698
assert len (failures ) == 1
697
- expectederror = "MarkerError: test_foo has 'parameterize ', spelling should be 'parametrize'"
699
+ expectederror = "MarkerError: test_foo has '{0} ', spelling should be 'parametrize'" . format ( attr )
698
700
assert expectederror in failures [0 ].longrepr .reprcrash .message
699
701
700
702
You can’t perform that action at this time.
0 commit comments