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
|
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.
|
- add support for setUpModule/tearDownModule detection, thanks Brian Okken.
|
||||||
|
|
||||||
- make sessionfinish hooks execute with the same cwd-context as at
|
- 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):
|
def parametrize_sorted(items, ignore, cache, scopenum):
|
||||||
if scopenum >= 3:
|
if scopenum >= 3:
|
||||||
return items
|
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 = []
|
similar_items = []
|
||||||
other_items = []
|
other_items = []
|
||||||
slicing_argparam = None
|
slicing_argparam = None
|
||||||
|
slicing_index = 0
|
||||||
for item in items:
|
for item in items:
|
||||||
argparamlist = getfuncargparams(item, ignore, scopenum, cache)
|
argparamlist = getfuncargparams(item, ignore, scopenum, cache)
|
||||||
if slicing_argparam is None and argparamlist:
|
if slicing_argparam is None and argparamlist:
|
||||||
|
@ -1759,7 +1766,8 @@ def parametrize_sorted(items, ignore, cache, scopenum):
|
||||||
similar_items.append(item)
|
similar_items.append(item)
|
||||||
else:
|
else:
|
||||||
other_items.append(item)
|
other_items.append(item)
|
||||||
if similar_items:
|
|
||||||
|
if (len(similar_items) + slicing_index) > 1:
|
||||||
newignore = ignore.copy()
|
newignore = ignore.copy()
|
||||||
newignore.add(slicing_argparam)
|
newignore.add(slicing_argparam)
|
||||||
part2 = parametrize_sorted(
|
part2 = parametrize_sorted(
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -12,7 +12,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.4.0.dev4',
|
version='2.4.0.dev5',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -555,6 +555,20 @@ class TestMetafuncFunctional:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=5)
|
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):
|
def test_usefixtures_seen_in_generate_tests(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -98,4 +98,4 @@ python_files=test_*.py *_test.py testing/*/*.py
|
||||||
python_classes=Test Acceptance
|
python_classes=Test Acceptance
|
||||||
python_functions=test
|
python_functions=test
|
||||||
pep8ignore = E401 E225 E261 E128 E124 E302
|
pep8ignore = E401 E225 E261 E128 E124 E302
|
||||||
norecursedirs = .tox ja
|
norecursedirs = .tox ja .hg
|
||||||
|
|
Loading…
Reference in New Issue