Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.6
Changeset: r69612:9bf739c1dbf9
Date: 2014-03-02 06:51 -0500
http://bitbucket.org/pypy/pypy/changeset/9bf739c1dbf9/
Log: cleanup some duplicated tests
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -1,4 +1,3 @@
-
import _rawffi
from _rawffi import alt as _ffi
import sys
diff --git a/pypy/module/_rawffi/test/test__rawffi.py
b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -512,38 +512,6 @@
assert (y.a, y.b, y.c) == (-1, -7, 0)
y.free()
- def test_structure_bitfields_longlong(self):
- import _rawffi
- Z = _rawffi.Structure([('a', 'Q', 1),
- ('b', 'Q', 62),
- ('c', 'Q', 1)])
- z = Z()
- z.a, z.b, z.c = 7, 0x1000000000000001, 7
- assert (z.a, z.b, z.c) == (1, 0x1000000000000001, 1)
- z.free()
-
- def test_structure_ulonglong_bitfields(self):
- import _rawffi
- X = _rawffi.Structure([('A', 'Q', 1),
- ('B', 'Q', 62),
- ('C', 'Q', 1)])
- x = X()
- x.A, x.B, x.C = 7, 0x1000000000000001, 7
- assert x.A == 1
- assert x.B == 0x1000000000000001
- assert x.C == 1
- x.free()
-
- def test_structure_longlong_bitfields(self):
- import _rawffi
- Y = _rawffi.Structure([('a', 'q', 1),
- ('b', 'q', 61),
- ('c', 'q', 1)])
- y = Y()
- y.a, y.b, y.c = 0, -7, 0
- assert (y.a, y.b, y.c) == (0, -7, 0)
- y.free()
-
def test_structure_ulonglong_bitfields(self):
import _rawffi
X = _rawffi.Structure([('A', 'Q', 1),
@@ -742,7 +710,6 @@
finally:
sys.stderr = orig
-
def test_setattr_struct(self):
import _rawffi
X = _rawffi.Structure([('value1', 'i'), ('value2', 'i')])
@@ -773,7 +740,6 @@
assert s.value == 4
s.free()
-
def test_array_addressof(self):
import _rawffi
lib = _rawffi.CDLL(self.lib_name)
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_bitfields.py
b/pypy/module/test_lib_pypy/ctypes_tests/test_bitfields.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_bitfields.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_bitfields.py
@@ -5,6 +5,11 @@
import ctypes
+signed_int_types = (c_byte, c_short, c_int, c_long, c_longlong)
+unsigned_int_types = (c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong)
+int_types = unsigned_int_types + signed_int_types
+
+
def setup_module(mod):
import conftest
_ctypes_test = str(conftest.sofile)
@@ -12,6 +17,7 @@
func.argtypes = POINTER(BITS), c_char
mod.func = func
+
class BITS(Structure):
_fields_ = [("A", c_int, 1),
("B", c_int, 2),
@@ -32,9 +38,7 @@
("S", c_short, 7)]
-
class TestC:
-
def test_ints(self):
for i in range(512):
for name in "ABCDEFGHI":
@@ -49,12 +53,8 @@
setattr(b, name, i)
assert (name, i, getattr(b, name)) == (name, i, func(byref(b),
name))
-signed_int_types = (c_byte, c_short, c_int, c_long, c_longlong)
-unsigned_int_types = (c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong)
-int_types = unsigned_int_types + signed_int_types
class TestBitField:
-
def test_longlong(self):
class X(Structure):
_fields_ = [("a", c_longlong, 1),
@@ -98,7 +98,6 @@
x.a, x.b = 0, -1
assert (c_typ, x.a, x.b, x.c) == (c_typ, 0, -1, 0)
-
def test_unsigned(self):
for c_typ in unsigned_int_types:
class X(Structure):
@@ -114,7 +113,6 @@
x.a, x.b = 0, -1
assert (c_typ, x.a, x.b, x.c) == (c_typ, 0, 7, 0)
-
def fail_fields(self, *fields):
return self.get_except(type(Structure), "X", (),
{"_fields_": fields})
@@ -194,7 +192,6 @@
assert X.b.offset == sizeof(c_short)*1
assert X.c.offset == sizeof(c_short)*2
-
def get_except(self, func, *args, **kw):
try:
func(*args, **kw)
@@ -245,7 +242,6 @@
A._fields_ = [("a", POINTER(A)),
("b", c_ubyte, 4)]
-
def test_set_fields_cycle_fails(self):
class A(Structure):
pass
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
b/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
@@ -4,6 +4,7 @@
import py
+
class TestSubclasses(BaseCTypesTestChecker):
def test_subclass(self):
class X(Structure):
@@ -45,6 +46,7 @@
assert Y._fields_ == [("b", c_int)]
assert Z._fields_ == [("a", c_int)]
+
class TestStructure(BaseCTypesTestChecker):
formats = {"c": c_char,
"b": c_byte,
@@ -163,7 +165,6 @@
# offset is always relative to the class...
def test_packed(self):
- py.test.skip("custom alignment not supported")
class X(Structure):
_fields_ = [("a", c_byte),
("b", c_longlong)]
@@ -242,7 +243,6 @@
# Try a second time, result may be different (cf. issue1498)
pos = POSITION(1, 2)
assert (pos.x, pos.y) == (1, 2)
-
def test_invalid_field_types(self):
class POINT(Structure):
@@ -460,8 +460,8 @@
class X(Structure):
_fields_ = [(u"i", c_int)]
+
class TestPointerMember(BaseCTypesTestChecker):
-
def test_1(self):
# a Structure with a POINTER field
class S(Structure):
@@ -515,7 +515,6 @@
else:
raise AssertionError, "Structure or union cannot contain itself"
-
def test_vice_versa(self):
py.test.skip("mutually dependent lazily defined structures error
semantics")
class First(Structure):
@@ -563,4 +562,3 @@
x = X()
assert x.x == 0
-
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit