Author: Ronan Lamy <[email protected]>
Branch: cleanup-test_lib_pypy
Changeset: r95466:74de35e03dac
Date: 2018-12-12 22:13 +0000
http://bitbucket.org/pypy/pypy/changeset/74de35e03dac/
Log: Allow (most) ctypes tests to run on CPython and add
@pytest.mark.pypy_only
diff --git a/extra_tests/ctypes_tests/conftest.py
b/extra_tests/ctypes_tests/conftest.py
--- a/extra_tests/ctypes_tests/conftest.py
+++ b/extra_tests/ctypes_tests/conftest.py
@@ -3,10 +3,6 @@
import sys
import os
-def pytest_ignore_collect(path):
- if '__pypy__' not in sys.builtin_module_names:
- return True
-
# XXX: copied from pypy/tool/cpyext/extbuild.py
if os.name != 'nt':
so_ext = 'so'
diff --git a/extra_tests/ctypes_tests/test_anon.py
b/extra_tests/ctypes_tests/test_anon.py
--- a/extra_tests/ctypes_tests/test_anon.py
+++ b/extra_tests/ctypes_tests/test_anon.py
@@ -1,6 +1,7 @@
import pytest
from ctypes import *
[email protected]_only
def test_nested():
class ANON_S(Structure):
_fields_ = [("a", c_int)]
diff --git a/extra_tests/ctypes_tests/test_base.py
b/extra_tests/ctypes_tests/test_base.py
--- a/extra_tests/ctypes_tests/test_base.py
+++ b/extra_tests/ctypes_tests/test_base.py
@@ -1,6 +1,7 @@
+import pytest
from ctypes import *
-# WhiteBoxTests
+pytestmark = pytest.mark.pypy_only
def test_pointer():
p = pointer(pointer(c_int(2)))
diff --git a/extra_tests/ctypes_tests/test_functions.py
b/extra_tests/ctypes_tests/test_functions.py
--- a/extra_tests/ctypes_tests/test_functions.py
+++ b/extra_tests/ctypes_tests/test_functions.py
@@ -57,6 +57,7 @@
result = f("abcd", ord("b"))
assert result == "bcd"
[email protected]_only
def test_keepalive_buffers(monkeypatch, dll):
import gc
f = dll.my_strchr
@@ -111,6 +112,7 @@
u = dll.ret_un_func(a[1])
assert u.y == 33 * 10000
[email protected]_only
def test_cache_funcptr(dll):
tf_b = dll.tf_b
tf_b.restype = c_byte
diff --git a/extra_tests/ctypes_tests/test_guess_argtypes.py
b/extra_tests/ctypes_tests/test_guess_argtypes.py
--- a/extra_tests/ctypes_tests/test_guess_argtypes.py
+++ b/extra_tests/ctypes_tests/test_guess_argtypes.py
@@ -1,15 +1,14 @@
""" This test checks whether args wrapping behavior is correct
"""
-import py
+import pytest
import sys
from ctypes import *
[email protected]_only
def test_wrap_args():
- if not hasattr(sys, 'pypy_translation_info'):
- py.test.skip("pypy white-box test")
- from _ctypes.function import CFuncPtr
+ from _ctypes import CFuncPtr
def guess(value):
_, cobj, ctype = CFuncPtr._conv_param(None, value)
@@ -33,7 +32,7 @@
def test_guess_unicode(dll):
if not hasattr(sys, 'pypy_translation_info') and sys.platform != 'win32':
- py.test.skip("CPython segfaults: see http://bugs.python.org/issue5203")
+ pytest.skip("CPython segfaults: see http://bugs.python.org/issue5203")
wcslen = dll.my_wcslen
text = u"Some long unicode string"
assert wcslen(text) == len(text)
diff --git a/extra_tests/ctypes_tests/test_keepalive.py
b/extra_tests/ctypes_tests/test_keepalive.py
--- a/extra_tests/ctypes_tests/test_keepalive.py
+++ b/extra_tests/ctypes_tests/test_keepalive.py
@@ -104,7 +104,7 @@
assert p._objects.keys() == ['1']
assert p._objects['1'].value == 3
[email protected]("'__pypy__' not in sys.builtin_module_names")
[email protected]_only
def test_primitive():
assert c_char_p("abc")._objects._buffer[0] == "a"
assert c_int(3)._objects is None
diff --git a/extra_tests/ctypes_tests/test_pointers.py
b/extra_tests/ctypes_tests/test_pointers.py
--- a/extra_tests/ctypes_tests/test_pointers.py
+++ b/extra_tests/ctypes_tests/test_pointers.py
@@ -1,6 +1,7 @@
import pytest
from ctypes import *
[email protected]_only
def test_get_ffi_argtype():
P = POINTER(c_int)
ffitype = P.get_ffi_argtype()
@@ -61,6 +62,7 @@
for i in [0, 1, 4, 1444, -10293]:
assert cast(byref(c, i), c_void_p).value == base + i
[email protected]_only
def test_issue2813_fix():
class C(Structure):
pass
@@ -70,6 +72,7 @@
assert C.get_ffi_argtype() is ffitype
assert ffitype.sizeof() == sizeof(c_int)
[email protected]_only
def test_issue2813_cant_change_fields_after_get_ffi_argtype():
class C(Structure):
pass
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit