[pypy-svn] r51721 - pypy/dist/pypy/lib/app_test/ctypes
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Feb 21 14:40:06 CET 2008
Author: cfbolz
Date: Thu Feb 21 14:40:06 2008
New Revision: 51721
Modified:
pypy/dist/pypy/lib/app_test/ctypes/test_structures.py
Log:
move the tuple test. wrote another one, which passes but leaks memory :-(
Modified: pypy/dist/pypy/lib/app_test/ctypes/test_structures.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_structures.py (original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_structures.py Thu Feb 21 14:40:06 2008
@@ -316,6 +316,7 @@
def get_except(self, func, *args):
+ # XXX remove this, py.test.raises returns a nice inspectable object
try:
func(*args)
except Exception, detail:
@@ -346,6 +347,31 @@
assert "from_address" in dir(type(Structure))
assert "in_dll" in dir(type(Structure))
+ def test_fields_is_a_tuple(self):
+ class Person(Structure):
+ _fields_ = (("name", c_char*6),
+ ("age", c_int))
+
+ # short enough
+ p = Person("123456", 6)
+ assert p.name == "123456"
+ assert p.age == 6
+
+ def test_subclassing_field_is_a_tuple(self):
+ py.test.skip("this leaks")
+ class Person(Structure):
+ _fields_ = (("name", c_char*6),
+ ("age", c_int))
+ class PersonWithIncome(Person):
+ _fields_ = [("income", c_int)]
+
+ # short enough
+ p = PersonWithIncome("123456", 6, 5)
+ assert p.name == "123456"
+ assert p.age == 6
+ assert p.income == 5
+
+
class TestPointerMember(BaseCTypesTestChecker):
def test_1(self):
@@ -387,15 +413,6 @@
s.p = None
assert s.x == 12345678
- def test_fields_is_a_tuple(self):
- class Person(Structure):
- _fields_ = (("name", c_char*6),
- ("age", c_int))
-
- # short enough
- p = Person("123456", 6)
- assert p.name == "123456"
- assert p.age == 6
class TestRecursiveStructure(BaseCTypesTestChecker):
def test_contains_itself(self):
More information about the Pypy-commit
mailing list