Skip to content

Commit d217b52

Browse files
fix #510 by adding a describing skip marker on empty parameterize
1 parent 436e13a commit d217b52

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

CHANGELOG.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
**Bug Fixes**
55

6-
*
6+
* fix `#510`_: skip tests where one parameterize dimension was empty
7+
thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR
78

8-
* Fix win32 path issue when puttinging custom config file with absolute path
9+
* Fix win32 path issue when puttinging custom config file with absolute path
910
in ``pytest.main("-c your_absolute_path")``.
1011

1112
* Fix maximum recursion depth detection when raised error class is not aware
@@ -78,7 +79,7 @@
7879
``xfail_strict`` ini option that can be used to configure it project-wise.
7980
Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_).
8081

81-
* ``Parser.addini`` now supports options of type ``bool``.
82+
* ``Parser.addini`` now supports options of type ``bool``.
8283
Thanks `@nicoddemus`_ for the PR.
8384

8485
* New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings
@@ -89,25 +90,25 @@
8990
Fixes `#1366`_.
9091
Thanks to `@hpk42`_ for the report and `@RonnyPfannschmidt`_ for the PR.
9192

92-
* Catch ``IndexError`` exceptions when getting exception source location.
93+
* Catch ``IndexError`` exceptions when getting exception source location.
9394
Fixes a pytest internal error for dynamically generated code (fixtures and tests)
9495
where source lines are fake by intention.
9596

9697
**Changes**
9798

9899
* **Important**: `py.code <https://pylib.readthedocs.io/en/latest/code.html>`_ has been
99-
merged into the ``pytest`` repository as ``pytest._code``. This decision
100-
was made because ``py.code`` had very few uses outside ``pytest`` and the
101-
fact that it was in a different repository made it difficult to fix bugs on
100+
merged into the ``pytest`` repository as ``pytest._code``. This decision
101+
was made because ``py.code`` had very few uses outside ``pytest`` and the
102+
fact that it was in a different repository made it difficult to fix bugs on
102103
its code in a timely manner. The team hopes with this to be able to better
103104
refactor out and improve that code.
104105
This change shouldn't affect users, but it is useful to let users aware
105106
if they encounter any strange behavior.
106-
107-
Keep in mind that the code for ``pytest._code`` is **private** and
107+
108+
Keep in mind that the code for ``pytest._code`` is **private** and
108109
**experimental**, so you definitely should not import it explicitly!
109110

110-
Please note that the original ``py.code`` is still available in
111+
Please note that the original ``py.code`` is still available in
111112
`pylib <https://pylib.readthedocs.io>`_.
112113

113114
* ``pytest_enter_pdb`` now optionally receives the pytest config object.
@@ -201,7 +202,7 @@
201202
- fix #1292: monkeypatch calls (setattr, setenv, etc.) are now O(1).
202203
Thanks David R. MacIver for the report and Bruno Oliveira for the PR.
203204

204-
- fix #1223: captured stdout and stderr are now properly displayed before
205+
- fix #1223: captured stdout and stderr are now properly displayed before
205206
entering pdb when ``--pdb`` is used instead of being thrown away.
206207
Thanks Cal Leeming for the PR.
207208

@@ -276,8 +277,8 @@
276277
Thanks Gabriel Reis for the PR.
277278

278279
- add more talks to the documentation
279-
- extend documentation on the --ignore cli option
280-
- use pytest-runner for setuptools integration
280+
- extend documentation on the --ignore cli option
281+
- use pytest-runner for setuptools integration
281282
- minor fixes for interaction with OS X El Capitan
282283
system integrity protection (thanks Florian)
283284

_pytest/python.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,13 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
990990
argvalues = [(val,) for val in argvalues]
991991
if not argvalues:
992992
argvalues = [(_notexists,) * len(argnames)]
993+
# we passed a empty list to parameterize, skip that test
994+
#
995+
newmark = pytest.mark.skip(
996+
reason='argument listing for %r was empty' % argnames)
997+
newmarks = newkeywords.setdefault(0, {})
998+
newmarks[newmark.markname] = newmark
999+
9931000

9941001
if scope is None:
9951002
scope = "function"

testing/python/metafunc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ def func(x, y): pass
109109
metafunc.parametrize(("x","y"), [("abc", "def"),
110110
("ghi", "jkl")], ids=["one"]))
111111

112+
@pytest.mark.issue510
113+
def test_parametrize_empty_list(self):
114+
def func( y): pass
115+
metafunc = self.Metafunc(func)
116+
metafunc.parametrize("y", [])
117+
assert 'skip' in metafunc._calls[0].keywords
118+
112119
def test_parametrize_with_userobjects(self):
113120
def func(x, y): pass
114121
metafunc = self.Metafunc(func)

0 commit comments

Comments
 (0)