Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r89425:b7c079c171ab
Date: 2017-01-08 17:27 +0100
http://bitbucket.org/pypy/pypy/changeset/b7c079c171ab/

Log:    Fix test_inspect_types (shows real failures now)

diff --git a/lib-python/3/test/test_decimal.py 
b/lib-python/3/test/test_decimal.py
--- a/lib-python/3/test/test_decimal.py
+++ b/lib-python/3/test/test_decimal.py
@@ -35,7 +35,7 @@
 from test.support import (run_unittest, run_doctest, is_resource_enabled,
                           requires_IEEE_754, requires_docstrings)
 from test.support import (check_warnings, import_fresh_module, TestFailed,
-                          run_with_locale, cpython_only)
+                          run_with_locale, cpython_only, check_impl_detail)
 import random
 import time
 import warnings
@@ -5452,6 +5452,7 @@
 
         POS = inspect._ParameterKind.POSITIONAL_ONLY
         POS_KWD = inspect._ParameterKind.POSITIONAL_OR_KEYWORD
+        KWONLY = inspect._ParameterKind.KEYWORD_ONLY
 
         # Type heuristic (type annotations would help!):
         pdict = {C: {'other': C.Decimal(1),
@@ -5489,6 +5490,8 @@
                     args.append(pdict[module][name])
                 elif param.kind == POS_KWD:
                     kwargs[name] = pdict[module][name]
+                elif param.kind == KWONLY:
+                    pass
                 else:
                     raise TestFailed("unexpected parameter kind")
             return args, kwargs
@@ -5517,15 +5520,26 @@
                     p_names = list(p_sig.parameters.keys())
                     c_names = [tr(x) for x in c_sig.parameters.keys()]
 
+                    p_kind = [x.kind for x in p_sig.parameters.values()]
+                    c_kind = [x.kind for x in c_sig.parameters.values()]
+
+                    if check_impl_detail(pypy=True):
+                        # PyPy only: _decimal.py has some methods with
+                        # an extra keyword-only argument 'strict', which
+                        # we ignore here
+                        if c_names[-1:] == ['strict'] and c_kind[-1] == KWONLY:
+                            del c_names[-1]
+                            del c_kind[-1]
+
                     self.assertEqual(c_names, p_names,
                                      msg="parameter name mismatch in %s" % 
p_func)
 
-                    p_kind = [x.kind for x in p_sig.parameters.values()]
-                    c_kind = [x.kind for x in c_sig.parameters.values()]
-
                     # 'self' parameter:
                     self.assertIs(p_kind[0], POS_KWD)
-                    self.assertIs(c_kind[0], POS)
+                    if check_impl_detail(cpython=True):
+                        self.assertIs(c_kind[0], POS)
+                    else:
+                        self.assertIs(c_kind[0], POS_KWD)
 
                     # remaining parameters:
                     if ty == 'Decimal':
diff --git a/lib_pypy/_decimal.py b/lib_pypy/_decimal.py
--- a/lib_pypy/_decimal.py
+++ b/lib_pypy/_decimal.py
@@ -1264,7 +1264,7 @@
         return Decimal._from_float(value, self, exact=False)
 
     # operations
-    def _convert_unaryop(self, a, strict=True):
+    def _convert_unaryop(self, a, *, strict=True):
         if isinstance(a, Decimal):
             return a
         elif isinstance(a, int):
@@ -1274,7 +1274,7 @@
         else:
             return NotImplemented
 
-    def _convert_binop(self, a, b, strict=True):
+    def _convert_binop(self, a, b, *, strict=True):
         a = self._convert_unaryop(a, strict=strict)
         b = self._convert_unaryop(b, strict=strict)
         if b is NotImplemented:
@@ -1441,7 +1441,7 @@
             _mpdec.mpd_qfinalize(result._mpd, ctx, status_ptr)
         return result
 
-    def divmod(self, a, b, strict=True):
+    def divmod(self, a, b, *, strict=True):
         a, b = self._convert_binop(a, b, strict=strict)
         if a is NotImplemented:
             return NotImplemented
@@ -1452,7 +1452,7 @@
                                ctx, status_ptr)
         return q, r
 
-    def power(self, a, b, modulo=None, strict=True):
+    def power(self, a, b, modulo=None, *, strict=True):
         a, b = self._convert_binop(a, b, strict=strict)
         if a is NotImplemented:
             return NotImplemented
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to