From 1ee3d40dbedb7c45418d89266a878f123da84bed Mon Sep 17 00:00:00 2001 From: palaviv Date: Sun, 13 Mar 2016 23:37:21 +0200 Subject: [PATCH 1/3] allow parametrized nodes to be specified from command line --- _pytest/main.py | 2 +- testing/test_mark.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/_pytest/main.py b/_pytest/main.py index 70d6896cb..f3f3be2c1 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -718,7 +718,7 @@ class Session(FSCollector): if rep.passed: has_matched = False for x in rep.result: - if x.name == name: + if x.name == name or x.name.split("[")[0] == name: resultnodes.extend(self.matchnodes([x], nextnames)) has_matched = True # XXX accept IDs that don't have "()" for class instances diff --git a/testing/test_mark.py b/testing/test_mark.py index 1795928f0..aa1be6f7c 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -269,6 +269,22 @@ def test_keyword_option_parametrize(spec, testdir): assert len(passed) == len(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: def test_mark_per_function(self, testdir): From 981fcb279800716482dd600f3346caad99054d05 Mon Sep 17 00:00:00 2001 From: palaviv Date: Sun, 13 Mar 2016 23:47:41 +0200 Subject: [PATCH 2/3] added CHANGELOG and AUTHORS entry --- AUTHORS | 1 + CHANGELOG.rst | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 4546b3178..b3659fcd3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Andy Freeland Anthon van der Neut Armin Rigo Aron Curzon +Aviv Palivoda Benjamin Peterson Bob Ippolito Brian Dorsey diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c81f342b0..159504c87 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -25,7 +25,7 @@ * Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize 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 .. _#469: https://github.com/pytest-dev/pytest/issues/469 .. _#1431: https://github.com/pytest-dev/pytest/pull/1431 +.. _#649: https://github.com/pytest-dev/pytest/issues/649 .. _@asottile: https://github.com/asottile From a1277aaf0e0be3cf9e2834378422929abb4c4426 Mon Sep 17 00:00:00 2001 From: palaviv Date: Tue, 15 Mar 2016 23:42:25 +0200 Subject: [PATCH 3/3] added TODO comment to remove the parametrized workaround --- _pytest/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_pytest/main.py b/_pytest/main.py index f3f3be2c1..8654d7af6 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -718,6 +718,7 @@ class Session(FSCollector): if rep.passed: has_matched = False for x in rep.result: + # 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)) has_matched = True