FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-97588: Failing tests to demonstrate the issue by matthiasgoergens · Pull Request #97589 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
74 changes: 74 additions & 0 deletions Lib/test/test_ctypes/test_bitfields.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add failing tests to document problems with ctypes structs.

Back | FazBrowse Home | New Git URL