Fix internal error when parametrizing using and empty list of ids()
Fix #1849
This commit is contained in:
parent
7538680c98
commit
df200297e2
|
@ -8,12 +8,14 @@
|
||||||
with normal parameters in the same call (`#1832`_).
|
with normal parameters in the same call (`#1832`_).
|
||||||
Thanks `@The-Compiler`_ for the report, `@Kingdread`_ and `@nicoddemus`_ for the PR.
|
Thanks `@The-Compiler`_ for the report, `@Kingdread`_ and `@nicoddemus`_ for the PR.
|
||||||
|
|
||||||
|
* Fix internal error when parametrizing tests or fixtures using an empty ``ids`` argument (`#1849`_).
|
||||||
|
Thanks `@OPpuolitaival`_ for the report and `@nicoddemus`_ for the PR.
|
||||||
|
|
||||||
* Fix loader error when running ``pytest`` embedded in a zipfile.
|
* Fix loader error when running ``pytest`` embedded in a zipfile.
|
||||||
Thanks `@mbachry`_ for the PR.
|
Thanks `@mbachry`_ for the PR.
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
*
|
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
|
@ -21,9 +23,11 @@
|
||||||
|
|
||||||
.. _@Kingdread: https://github.com/Kingdread
|
.. _@Kingdread: https://github.com/Kingdread
|
||||||
.. _@mbachry: https://github.com/mbachry
|
.. _@mbachry: https://github.com/mbachry
|
||||||
|
.. _@OPpuolitaival: https://github.com/OPpuolitaival
|
||||||
|
|
||||||
.. _#1822: https://github.com/pytest-dev/pytest/issues/1822
|
.. _#1822: https://github.com/pytest-dev/pytest/issues/1822
|
||||||
.. _#1832: https://github.com/pytest-dev/pytest/issues/1832
|
.. _#1832: https://github.com/pytest-dev/pytest/issues/1832
|
||||||
|
.. _#1849: https://github.com/pytest-dev/pytest/issues/1849
|
||||||
|
|
||||||
|
|
||||||
3.0.0
|
3.0.0
|
||||||
|
|
|
@ -936,7 +936,7 @@ def _idval(val, argname, idx, idfn, config=None):
|
||||||
return str(argname)+str(idx)
|
return str(argname)+str(idx)
|
||||||
|
|
||||||
def _idvalset(idx, valset, argnames, idfn, ids, config=None):
|
def _idvalset(idx, valset, argnames, idfn, ids, config=None):
|
||||||
if ids is None or ids[idx] is None:
|
if ids is None or (idx >= len(ids) or ids[idx] is None):
|
||||||
this_id = [_idval(val, argname, idx, idfn, config)
|
this_id = [_idval(val, argname, idx, idfn, config)
|
||||||
for val, argname in zip(valset, argnames)]
|
for val, argname in zip(valset, argnames)]
|
||||||
return "-".join(this_id)
|
return "-".join(this_id)
|
||||||
|
|
|
@ -889,6 +889,33 @@ class TestMetafuncFunctional:
|
||||||
"*test_function*advanced*FAILED",
|
"*test_function*advanced*FAILED",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_fixture_parametrized_empty_ids(self, testdir):
|
||||||
|
"""Fixtures parametrized with empty ids cause an internal error (#1849)."""
|
||||||
|
testdir.makepyfile('''
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module", ids=[], params=[])
|
||||||
|
def temp(request):
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
def test_temp(temp):
|
||||||
|
pass
|
||||||
|
''')
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines(['* 1 skipped *'])
|
||||||
|
|
||||||
|
def test_parametrized_empty_ids(self, testdir):
|
||||||
|
"""Tests parametrized with empty ids cause an internal error (#1849)."""
|
||||||
|
testdir.makepyfile('''
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('temp', [], ids=list())
|
||||||
|
def test_temp(temp):
|
||||||
|
pass
|
||||||
|
''')
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines(['* 1 skipped *'])
|
||||||
|
|
||||||
def test_parametrize_with_identical_ids_get_unique_names(self, testdir):
|
def test_parametrize_with_identical_ids_get_unique_names(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
Loading…
Reference in New Issue