Skip to content

gh-97588: Failing tests to demonstrate the issue #97589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
74 changes: 74 additions & 0 deletions Lib/test/test_ctypes/test_bitfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from test import support
import unittest
import os
import sys

import _ctypes_test

Expand Down Expand Up @@ -236,6 +237,79 @@ class X(Structure):
else:
self.assertEqual(sizeof(X), sizeof(c_int) * 2)

@unittest.skipIf(sys.platform == 'win32', "Doesn't fail on Windows")
@unittest.expectedFailure # gh-97588
def test_mixed_5(self):
class X(Structure):
_fields_ = [
('A', c_uint, 1),
('B', c_ushort, 16)]
a = X()
a.A = 0
a.B = 1
self.assertEqual(1, a.B)

@unittest.skipIf(sys.platform == 'win32', "Doesn't fail on Windows")
@unittest.expectedFailure # gh-97588
def test_mixed_6(self):
class X(Structure):
_fields_ = [
('A', c_ulonglong, 1),
('B', c_uint, 32)]
a = X()
a.A = 0
a.B = 1
self.assertEqual(1, a.B)

@unittest.skipIf(sys.platform == 'win32', "Doesn't fail on Windows")
@unittest.expectedFailure # gh-97588
def test_mixed_7(self):
class X(Structure):
_fields_ = [
("A", c_uint),
('B', c_uint, 20),
('C', c_ulonglong, 24)]
self.assertEqual(16, sizeof(X))

@unittest.skipIf(sys.platform == 'win32', "Doesn't fail on Windows")
@unittest.expectedFailure # gh-97588
def test_mixed_8(self):
class Foo(Structure):
_fields_ = [
("A", c_uint),
("B", c_uint, 32),
("C", c_ulonglong, 1),
]

class Bar(Structure):
_fields_ = [
("A", c_uint),
("B", c_uint),
("C", c_ulonglong, 1),
]
self.assertEqual(sizeof(Foo), sizeof(Bar))

@unittest.skipIf(sys.platform == 'win32', "Doesn't fail on Windows")
@unittest.expectedFailure # gh-97588
def test_mixed_9(self):
class X(Structure):
_fields_ = [
("A", c_uint8),
("B", c_uint, 1),
]
self.assertEqual(4, sizeof(X))

@unittest.skipIf(sys.platform == 'win32', "Doesn't fail on Windows")
@unittest.expectedFailure # gh-97588
def test_mixed_10(self):
class X(Structure):
_fields_ = [
("A", c_uint32, 1),
("B", c_uint64, 1),
]
self.assertEqual(8, alignment(X))
self.assertEqual(8, sizeof(X))

def test_anon_bitfields(self):
# anonymous bit-fields gave a strange error message
class X(Structure):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add failing tests to document problems with ctypes structs.