From 4518b9af3aa1f8d605609d70731d8542a62091a5 2016-07-29 21:58:57 From: Danilo J. S. Bellini Date: 2016-07-29 21:58:57 Subject: [PATCH] Add cpython2_only decorator The test_pretty.test_dictproxy now is properly skipped on PyPy --- diff --git a/IPython/lib/tests/test_pretty.py b/IPython/lib/tests/test_pretty.py index ebfcac7..49c835d 100644 --- a/IPython/lib/tests/test_pretty.py +++ b/IPython/lib/tests/test_pretty.py @@ -12,7 +12,8 @@ import types, string, ctypes import nose.tools as nt from IPython.lib import pretty -from IPython.testing.decorators import skip_without, py2_only, py3_only +from IPython.testing.decorators import (skip_without, py2_only, py3_only, + cpython2_only) from IPython.utils.py3compat import PY3, unicode_to_str if PY3: @@ -483,7 +484,7 @@ def test_mappingproxy(): for obj, expected in cases: nt.assert_equal(pretty.pretty(obj), expected) -@py2_only +@cpython2_only # In PyPy, types.DictProxyType is dict def test_dictproxy(): # This is the dictproxy constructor itself from the Python API, DP = ctypes.pythonapi.PyDictProxy_New diff --git a/IPython/testing/decorators.py b/IPython/testing/decorators.py index a337254..087555d 100644 --- a/IPython/testing/decorators.py +++ b/IPython/testing/decorators.py @@ -48,7 +48,7 @@ from .ipunittest import ipdoctest, ipdocstring from IPython.external.decorators import * # For onlyif_cmd_exists decorator -from IPython.utils.py3compat import string_types, which, PY2, PY3 +from IPython.utils.py3compat import string_types, which, PY2, PY3, PYPY #----------------------------------------------------------------------------- # Classes and functions @@ -336,6 +336,7 @@ skip_known_failure = knownfailureif(True,'This test is known to fail') known_failure_py3 = knownfailureif(sys.version_info[0] >= 3, 'This test is known to fail on Python 3.') +cpython2_only = skipif(PY3 or PYPY, "This test only runs on CPython 2.") py2_only = skipif(PY3, "This test only runs on Python 2.") py3_only = skipif(PY2, "This test only runs on Python 3.") diff --git a/IPython/utils/py3compat.py b/IPython/utils/py3compat.py index f42f55c..2e7f5bb 100644 --- a/IPython/utils/py3compat.py +++ b/IPython/utils/py3compat.py @@ -292,6 +292,7 @@ else: PY2 = not PY3 +PYPY = any(k.startswith("pypy") for k in dir(sys)) def annotate(**kwargs):