fix issue323 - parametrize() of many module-scoped params
This commit is contained in:
parent
469830fffa
commit
c4c966683c
|
@ -1,6 +1,8 @@
|
|||
Changes between 2.3.5 and 2.4.DEV
|
||||
-----------------------------------
|
||||
|
||||
- fix issue323 - sorting of many module-scoped arg parametrizations
|
||||
|
||||
- add support for setUpModule/tearDownModule detection, thanks Brian Okken.
|
||||
|
||||
- make sessionfinish hooks execute with the same cwd-context as at
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#
|
||||
__version__ = '2.4.0.dev4'
|
||||
__version__ = '2.4.0.dev5'
|
||||
|
|
|
@ -1747,9 +1747,16 @@ def getfuncargnames(function, startindex=None):
|
|||
def parametrize_sorted(items, ignore, cache, scopenum):
|
||||
if scopenum >= 3:
|
||||
return items
|
||||
|
||||
# we pick the first item which has a arg/param combo in the
|
||||
# requested scope and sort other items with the same combo
|
||||
# into "newitems" which then is a list of all items using this
|
||||
# arg/param.
|
||||
|
||||
similar_items = []
|
||||
other_items = []
|
||||
slicing_argparam = None
|
||||
slicing_index = 0
|
||||
for item in items:
|
||||
argparamlist = getfuncargparams(item, ignore, scopenum, cache)
|
||||
if slicing_argparam is None and argparamlist:
|
||||
|
@ -1759,7 +1766,8 @@ def parametrize_sorted(items, ignore, cache, scopenum):
|
|||
similar_items.append(item)
|
||||
else:
|
||||
other_items.append(item)
|
||||
if similar_items:
|
||||
|
||||
if (len(similar_items) + slicing_index) > 1:
|
||||
newignore = ignore.copy()
|
||||
newignore.add(slicing_argparam)
|
||||
part2 = parametrize_sorted(
|
||||
|
|
2
setup.py
2
setup.py
|
@ -12,7 +12,7 @@ def main():
|
|||
name='pytest',
|
||||
description='py.test: simple powerful testing with Python',
|
||||
long_description = long_description,
|
||||
version='2.4.0.dev4',
|
||||
version='2.4.0.dev5',
|
||||
url='http://pytest.org',
|
||||
license='MIT license',
|
||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||
|
|
|
@ -555,6 +555,20 @@ class TestMetafuncFunctional:
|
|||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=5)
|
||||
|
||||
def test_parametrize_issue323(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
@pytest.fixture(scope='module', params=range(966))
|
||||
def foo(request):
|
||||
return request.param
|
||||
|
||||
def test_it(foo):
|
||||
pass
|
||||
""")
|
||||
reprec = testdir.inline_run("--collectonly")
|
||||
assert not reprec.getcalls("pytest_internalerror")
|
||||
|
||||
def test_usefixtures_seen_in_generate_tests(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
|
Loading…
Reference in New Issue