[Jython-checkins] jython: Minor fix to test_inspect so that all tests in it pass

jim.baker jython-checkins at python.org
Sun Dec 21 07:10:36 CET 2014


https://hg.python.org/jython/rev/66357235ee2e
changeset:   7465:66357235ee2e
user:        Jim Baker <jim.baker at rackspace.com>
date:        Sat Dec 20 23:10:32 2014 -0700
summary:
  Minor fix to test_inspect so that all tests in it pass

It's possible to get both the tuple parameters AND the unpacked
parameters by using locals(). However, they are named differently in
CPython and Jython:

* For CPython, such tuple parameters are named '.1', '.2', etc.
* For Jython, they are actually the formal parameter, eg '(d, (e, f))'

test_inspect actually wants to ignore such tuple parameters when
verifying working with function signatures, given they are already
unpacked. Updated is_tuplename regex accordingly.

files:
  Lib/test/test_inspect.py |  11 +++++++++--
  1 files changed, 9 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -633,8 +633,15 @@
 
 class TestGetcallargsFunctions(unittest.TestCase):
 
-    # tuple parameters are named '.1', '.2', etc.
-    is_tuplename = re.compile(r'^\.\d+$').match
+    # It's possible to get both the tuple parameters AND the unpacked
+    # parameters by using locals(). However, they are named
+    # differently in CPython and Jython:
+    #
+    # * For CPython, such tuple parameters are named '.1', '.2', etc.
+    # * For Jython, they are actually the formal parameter, eg '(d, (e, f))'
+    #
+    # In both cases, we ignore in testing - they are in fact unpacked
+    is_tuplename = re.compile(r'(?:^\.\d+$)|(?:^\()').match
 
     def assertEqualCallArgs(self, func, call_params_string, locs=None):
         locs = dict(locs or {}, func=func)

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list