Merge pull request #1452 from palaviv/specify-paramterized-node-in-command-line

Specify paramterized node in command line - fixes #649
This commit is contained in:
Ronny Pfannschmidt 2016-03-16 11:16:54 +01:00
commit d70596da91
4 changed files with 21 additions and 2 deletions

View File

@ -10,6 +10,7 @@ Andy Freeland
Anthon van der Neut Anthon van der Neut
Armin Rigo Armin Rigo
Aron Curzon Aron Curzon
Aviv Palivoda
Benjamin Peterson Benjamin Peterson
Bob Ippolito Bob Ippolito
Brian Dorsey Brian Dorsey

View File

@ -25,7 +25,7 @@
* Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize * Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize
attempt to decode it as utf-8 ignoring errors. attempt to decode it as utf-8 ignoring errors.
* * Fix (`#649`_): parametrized test nodes cannot be specified to run on the command line.
* *
@ -33,6 +33,7 @@
.. _#1437: https://github.com/pytest-dev/pytest/issues/1437 .. _#1437: https://github.com/pytest-dev/pytest/issues/1437
.. _#469: https://github.com/pytest-dev/pytest/issues/469 .. _#469: https://github.com/pytest-dev/pytest/issues/469
.. _#1431: https://github.com/pytest-dev/pytest/pull/1431 .. _#1431: https://github.com/pytest-dev/pytest/pull/1431
.. _#649: https://github.com/pytest-dev/pytest/issues/649
.. _@asottile: https://github.com/asottile .. _@asottile: https://github.com/asottile

View File

@ -718,7 +718,8 @@ class Session(FSCollector):
if rep.passed: if rep.passed:
has_matched = False has_matched = False
for x in rep.result: for x in rep.result:
if x.name == name: # TODO: remove parametrized workaround once collection structure contains parametrization
if x.name == name or x.name.split("[")[0] == name:
resultnodes.extend(self.matchnodes([x], nextnames)) resultnodes.extend(self.matchnodes([x], nextnames))
has_matched = True has_matched = True
# XXX accept IDs that don't have "()" for class instances # XXX accept IDs that don't have "()" for class instances

View File

@ -269,6 +269,22 @@ def test_keyword_option_parametrize(spec, testdir):
assert len(passed) == len(passed_result) assert len(passed) == len(passed_result)
assert list(passed) == list(passed_result) assert list(passed) == list(passed_result)
def test_parametrized_collected_from_command_line(testdir):
"""Parametrized test not collected if test named specified
in command line issue#649.
"""
py_file = testdir.makepyfile("""
import pytest
@pytest.mark.parametrize("arg", [None, 1.3, "2-3"])
def test_func(arg):
pass
""")
file_name = os.path.basename(py_file.strpath)
rec = testdir.inline_run(file_name + "::" + "test_func")
rec.assertoutcome(passed=3)
class TestFunctional: class TestFunctional:
def test_mark_per_function(self, testdir): def test_mark_per_function(self, testdir):