Skip to content

Commit d70596d

Browse files
Merge pull request pytest-dev#1452 from palaviv/specify-paramterized-node-in-command-line
Specify paramterized node in command line - fixes pytest-dev#649
2 parents 19cec79 + a1277aa commit d70596d

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Andy Freeland
1010
Anthon van der Neut
1111
Armin Rigo
1212
Aron Curzon
13+
Aviv Palivoda
1314
Benjamin Peterson
1415
Bob Ippolito
1516
Brian Dorsey

CHANGELOG.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
* Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize
2626
attempt to decode it as utf-8 ignoring errors.
2727

28-
*
28+
* Fix (`#649`_): parametrized test nodes cannot be specified to run on the command line.
2929

3030
*
3131

3232

3333
.. _#1437: https://github.com/pytest-dev/pytest/issues/1437
3434
.. _#469: https://github.com/pytest-dev/pytest/issues/469
3535
.. _#1431: https://github.com/pytest-dev/pytest/pull/1431
36+
.. _#649: https://github.com/pytest-dev/pytest/issues/649
3637

3738
.. _@asottile: https://github.com/asottile
3839

_pytest/main.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ def _matchnodes(self, matching, names):
718718
if rep.passed:
719719
has_matched = False
720720
for x in rep.result:
721-
if x.name == name:
721+
# TODO: remove parametrized workaround once collection structure contains parametrization
722+
if x.name == name or x.name.split("[")[0] == name:
722723
resultnodes.extend(self.matchnodes([x], nextnames))
723724
has_matched = True
724725
# XXX accept IDs that don't have "()" for class instances

testing/test_mark.py

+16
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,22 @@ def test_func(arg):
269269
assert len(passed) == len(passed_result)
270270
assert list(passed) == list(passed_result)
271271

272+
273+
def test_parametrized_collected_from_command_line(testdir):
274+
"""Parametrized test not collected if test named specified
275+
in command line issue#649.
276+
"""
277+
py_file = testdir.makepyfile("""
278+
import pytest
279+
@pytest.mark.parametrize("arg", [None, 1.3, "2-3"])
280+
def test_func(arg):
281+
pass
282+
""")
283+
file_name = os.path.basename(py_file.strpath)
284+
rec = testdir.inline_run(file_name + "::" + "test_func")
285+
rec.assertoutcome(passed=3)
286+
287+
272288
class TestFunctional:
273289

274290
def test_mark_per_function(self, testdir):

0 commit comments

Comments
 (0)