[Pytest-commit] commit/pytest: hpk42: fix regression reported by dstufft: regression when a 1-tuple ("arg", ) is used

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Oct 2 08:09:21 CEST 2013


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/8f9abe7698e2/
Changeset:   8f9abe7698e2
User:        hpk42
Date:        2013-10-02 08:08:26
Summary:     fix regression reported by dstufft: regression when a 1-tuple ("arg",) is used
for specifying parametrization (the values of the parametrization were passed
nested in a tuple).
Affected #:  3 files

diff -r 00aface0eb2874e70545a09f71edf73a3753feb5 -r 8f9abe7698e264a3ef3d2c58678537ace8017cde CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,10 @@
 - fix dotted filename completion when using argcomplete 
   thanks Anthon van der Neuth. (fixes issue361)
 
+- fix regression when a 1-tuple ("arg",) is used for specifying
+  parametrization (the values of the parametrization were passed
+  nested in a tuple).  Thanks Donald Stufft.
+
 - merge doc typo fixes, thanks Andy Dirnberger
 
 Changes between 2.3.5 and 2.4

diff -r 00aface0eb2874e70545a09f71edf73a3753feb5 -r 8f9abe7698e264a3ef3d2c58678537ace8017cde _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -710,8 +710,8 @@
 
         if not isinstance(argnames, (tuple, list)):
             argnames = [x.strip() for x in argnames.split(",") if x.strip()]
-        if len(argnames) == 1:
-            argvalues = [(val,) for val in argvalues]
+            if len(argnames) == 1:
+                argvalues = [(val,) for val in argvalues]
         if not argvalues:
             argvalues = [(_notexists,) * len(argnames)]
 

diff -r 00aface0eb2874e70545a09f71edf73a3753feb5 -r 8f9abe7698e264a3ef3d2c58678537ace8017cde testing/python/collect.py
--- a/testing/python/collect.py
+++ b/testing/python/collect.py
@@ -316,6 +316,16 @@
         reprec = testdir.inline_run()
         reprec.assertoutcome(skipped=1)
 
+    def test_single_tuple_unwraps_values(self, testdir):
+        testdir.makepyfile("""
+            import pytest
+            @pytest.mark.parametrize(('arg',), [(1,)])
+            def test_function(arg):
+                assert arg == 1
+        """)
+        reprec = testdir.inline_run()
+        reprec.assertoutcome(passed=1)
+
     def test_issue213_parametrize_value_no_equal(self, testdir):
         testdir.makepyfile("""
             import pytest

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list