Visitar URL original
Enable ctypes by youknowone · Pull Request #6457 · RustPython/RustPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
mark failing test_ctypes
  • Loading branch information
youknowone committed Dec 23, 2025
commit 4a352344b6abf257c4050786f2bfd8036da0f715
2 changes: 2 additions & 0 deletions Lib/test/test_ctypes/test_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_address2pointer(self):
ptr = cast(address, POINTER(c_int))
self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_p2a_objects(self):
array = (c_char_p * 5)()
self.assertEqual(array._objects, None)
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_ctypes/test_dlerror.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class TestNullDlsym(unittest.TestCase):
this 'dlsym returned NULL -> throw Error' rule.
"""

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_null_dlsym(self):
import subprocess
import tempfile
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_ctypes/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def test_ints(self):
self.assertEqual(refcnt, sys.getrefcount(i))
self.assertEqual(ci._objects, None)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_c_char_p(self):
s = "Hello, World".encode("ascii")
refcnt = sys.getrefcount(s)
Expand Down Expand Up @@ -62,6 +64,8 @@ class Y(Structure):
x1.a, x2.b = 42, 93
self.assertEqual(y._objects, {"0": {}, "1": {}})

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_xxx(self):
class X(Structure):
_fields_ = [("a", c_char_p), ("b", c_char_p)]
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_ctypes/test_keeprefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def test_cint(self):
x = c_int(99)
self.assertEqual(x._objects, None)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_ccharp(self):
x = c_char_p()
self.assertEqual(x._objects, None)
Expand All @@ -33,6 +35,8 @@ class X(Structure):
x.b = 99
self.assertEqual(x._objects, None)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_ccharp_struct(self):
class X(Structure):
_fields_ = [("a", c_char_p),
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_ctypes/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@


def load_tests(loader, tests, pattern):
tests.addTest(doctest.DocTestSuite())
# TODO: RUSTPYTHON - doctest disabled due to null terminator in _objects
# tests.addTest(doctest.DocTestSuite())
return tests


Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_ctypes/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@


class PythonAPITestCase(unittest.TestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_PyBytes_FromStringAndSize(self):
PyBytes_FromStringAndSize = pythonapi.PyBytes_FromStringAndSize

Expand Down Expand Up @@ -57,6 +59,8 @@ def test_PyObj_FromPtr(self):
del pyobj
self.assertEqual(sys.getrefcount(s), ref)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_PyOS_snprintf(self):
PyOS_snprintf = pythonapi.PyOS_snprintf
PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_ctypes/test_random_things.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def test_FloatDivisionError(self):
with self.expect_unraisable(ZeroDivisionError):
cb(0.0)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_TypeErrorDivisionError(self):
cb = CFUNCTYPE(c_int, c_char_p)(callback_func)
err_msg = "unsupported operand type(s) for /: 'int' and 'bytes'"
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_ctypes/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ def test_undefined(self):
class PythonValuesTestCase(unittest.TestCase):
"""This test only works when python itself is a dll/shared library"""

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_optimizeflag(self):
# This test accesses the Py_OptimizeFlag integer, which is
# exported by the Python dll and should match the sys.flags value

opt = c_int.in_dll(pythonapi, "Py_OptimizeFlag").value
self.assertEqual(opt, sys.flags.optimize)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_frozentable(self):
# Python exports a PyImport_FrozenModules symbol. This is a
# pointer to an array of struct _frozen entries. The end of the
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_ctypes/test_win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class FunctionCallTestCase(unittest.TestCase):
@unittest.skipUnless('MSC' in sys.version, "SEH only supported by MSC")
@unittest.skipIf(sys.executable.lower().endswith('_d.exe'),
"SEH not enabled in debug builds")
# TODO: RUSTPYTHON - SEH not implemented
@unittest.skipIf("RustPython" in sys.version, "SEH not implemented in RustPython")
def test_SEH(self):
# Disable faulthandler to prevent logging the warning:
# "Windows fatal exception: access violation"
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_ctypes/test_win32_com_foreign_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class IPersist(IUnknown):

self.assertEqual(0, ppst.Release())

# TODO: RUSTPYTHON - COM iid parameter handling not implemented
@unittest.expectedFailure
def test_with_paramflags_and_iid(self):
class IUnknown(c_void_p):
QueryInterface = proto_query_interface(None, IID_IUnknown)
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ def test_WindowsError(self):

@unittest.skipUnless(sys.platform == 'win32',
'test specific to Windows')
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_windows_message(self):
"""Should fill in unknown error code in Windows error message"""
ctypes = import_module('ctypes')
Expand Down
3 changes: 0 additions & 3 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ def get_file_system(self, path):
return buf.value
# return None if the filesystem is unknown

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (ModuleNotFoundError: No module named '_ctypes')")
def test_large_time(self):
# Many filesystems are limited to the year 2038. At least, the test
# pass with NTFS filesystem.
Expand Down Expand Up @@ -2712,12 +2711,10 @@ def _kill(self, sig):
os.kill(proc.pid, sig)
self.assertEqual(proc.wait(), sig)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (ModuleNotFoundError: No module named '_ctypes')")
def test_kill_sigterm(self):
# SIGTERM doesn't mean anything special, but make sure it works
self._kill(signal.SIGTERM)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (ModuleNotFoundError: No module named '_ctypes')")
def test_kill_int(self):
# os.kill on Windows can take an int which gets set as the exit code
self._kill(100)
Expand Down
Loading