Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4518b9a

Browse files
committed
Add cpython2_only decorator
The test_pretty.test_dictproxy now is properly skipped on PyPy
1 parent fce2225 commit 4518b9a

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

IPython/lib/tests/test_pretty.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import nose.tools as nt
1313

1414
from IPython.lib import pretty
15-
from IPython.testing.decorators import skip_without, py2_only, py3_only
15+
from IPython.testing.decorators import (skip_without, py2_only, py3_only,
16+
cpython2_only)
1617
from IPython.utils.py3compat import PY3, unicode_to_str
1718

1819
if PY3:
@@ -483,7 +484,7 @@ def test_mappingproxy():
483484
for obj, expected in cases:
484485
nt.assert_equal(pretty.pretty(obj), expected)
485486

486-
@py2_only
487+
@cpython2_only # In PyPy, types.DictProxyType is dict
487488
def test_dictproxy():
488489
# This is the dictproxy constructor itself from the Python API,
489490
DP = ctypes.pythonapi.PyDictProxy_New

IPython/testing/decorators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from IPython.external.decorators import *
4949

5050
# For onlyif_cmd_exists decorator
51-
from IPython.utils.py3compat import string_types, which, PY2, PY3
51+
from IPython.utils.py3compat import string_types, which, PY2, PY3, PYPY
5252

5353
#-----------------------------------------------------------------------------
5454
# Classes and functions
@@ -336,6 +336,7 @@ def skip_file_no_x11(name):
336336
known_failure_py3 = knownfailureif(sys.version_info[0] >= 3,
337337
'This test is known to fail on Python 3.')
338338

339+
cpython2_only = skipif(PY3 or PYPY, "This test only runs on CPython 2.")
339340
py2_only = skipif(PY3, "This test only runs on Python 2.")
340341
py3_only = skipif(PY2, "This test only runs on Python 3.")
341342

IPython/utils/py3compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def execfile(fname, glob=None, loc=None, compiler=None):
292292

293293

294294
PY2 = not PY3
295+
PYPY = any(k.startswith("pypy") for k in dir(sys))
295296

296297

297298
def annotate(**kwargs):

0 commit comments

Comments
 (0)