summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_structmembers.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-04-03 01:40:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-04-03 01:40:24 (GMT)
commit80d8fd85a932ad6ec66922f41078965bd94bf645 (patch)
tree46337d278e20eb5cd5024b0153ce667fd1aa64e9 /Lib/test/test_structmembers.py
parenta811c16a261b9ec1718960d6acc90fad55e612af (diff)
downloadcpython-80d8fd85a932ad6ec66922f41078965bd94bf645.zip
cpython-80d8fd85a932ad6ec66922f41078965bd94bf645.tar.gz
cpython-80d8fd85a932ad6ec66922f41078965bd94bf645.tar.bz2
Merged revisions 79642,79644 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79642 | benjamin.peterson | 2010-04-02 20:08:34 -0500 (Fri, 02 Apr 2010) | 1 line split out large test function ........ r79644 | benjamin.peterson | 2010-04-02 20:28:57 -0500 (Fri, 02 Apr 2010) | 1 line give TypeError when trying to set T_STRING_INPLACE ........
Diffstat (limited to 'Lib/test/test_structmembers.py')
-rw-r--r--Lib/test/test_structmembers.py43
1 files changed, 27 insertions, 16 deletions
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index e1a0e6b..4eba7f0 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -20,17 +20,20 @@ ts=test_structmembersType(False, # T_BOOL
8, # T_ULONG
23, # T_PYSSIZET
9.99999,# T_FLOAT
- 10.1010101010 # T_DOUBLE
+ 10.1010101010, # T_DOUBLE
+ "hi" # T_STRING_INPLACE
)
class ReadWriteTests(unittest.TestCase):
- def test_types(self):
+
+ def test_bool(self):
ts.T_BOOL = True
self.assertEquals(ts.T_BOOL, True)
ts.T_BOOL = False
self.assertEquals(ts.T_BOOL, False)
self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
+ def test_byte(self):
ts.T_BYTE = CHAR_MAX
self.assertEquals(ts.T_BYTE, CHAR_MAX)
ts.T_BYTE = CHAR_MIN
@@ -38,6 +41,7 @@ class ReadWriteTests(unittest.TestCase):
ts.T_UBYTE = UCHAR_MAX
self.assertEquals(ts.T_UBYTE, UCHAR_MAX)
+ def test_short(self):
ts.T_SHORT = SHRT_MAX
self.assertEquals(ts.T_SHORT, SHRT_MAX)
ts.T_SHORT = SHRT_MIN
@@ -45,6 +49,7 @@ class ReadWriteTests(unittest.TestCase):
ts.T_USHORT = USHRT_MAX
self.assertEquals(ts.T_USHORT, USHRT_MAX)
+ def test_int(self):
ts.T_INT = INT_MAX
self.assertEquals(ts.T_INT, INT_MAX)
ts.T_INT = INT_MIN
@@ -52,6 +57,7 @@ class ReadWriteTests(unittest.TestCase):
ts.T_UINT = UINT_MAX
self.assertEquals(ts.T_UINT, UINT_MAX)
+ def test_long(self):
ts.T_LONG = LONG_MAX
self.assertEquals(ts.T_LONG, LONG_MAX)
ts.T_LONG = LONG_MIN
@@ -59,26 +65,27 @@ class ReadWriteTests(unittest.TestCase):
ts.T_ULONG = ULONG_MAX
self.assertEquals(ts.T_ULONG, ULONG_MAX)
+ def test_py_ssize_t(self):
ts.T_PYSSIZET = PY_SSIZE_T_MAX
self.assertEquals(ts.T_PYSSIZET, PY_SSIZE_T_MAX)
ts.T_PYSSIZET = PY_SSIZE_T_MIN
self.assertEquals(ts.T_PYSSIZET, PY_SSIZE_T_MIN)
- ## T_LONGLONG and T_ULONGLONG may not be present on some platforms
- if hasattr(ts, 'T_LONGLONG'):
- ts.T_LONGLONG = LLONG_MAX
- self.assertEquals(ts.T_LONGLONG, LLONG_MAX)
- ts.T_LONGLONG = LLONG_MIN
- self.assertEquals(ts.T_LONGLONG, LLONG_MIN)
+ @unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present")
+ def test_longlong(self):
+ ts.T_LONGLONG = LLONG_MAX
+ self.assertEquals(ts.T_LONGLONG, LLONG_MAX)
+ ts.T_LONGLONG = LLONG_MIN
+ self.assertEquals(ts.T_LONGLONG, LLONG_MIN)
- ts.T_ULONGLONG = ULLONG_MAX
- self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX)
+ ts.T_ULONGLONG = ULLONG_MAX
+ self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX)
- ## make sure these will accept a plain int as well as a long
- ts.T_LONGLONG = 3
- self.assertEquals(ts.T_LONGLONG, 3)
- ts.T_ULONGLONG = 4
- self.assertEquals(ts.T_ULONGLONG, 4)
+ ## make sure these will accept a plain int as well as a long
+ ts.T_LONGLONG = 3
+ self.assertEquals(ts.T_LONGLONG, 3)
+ ts.T_ULONGLONG = 4
+ self.assertEquals(ts.T_ULONGLONG, 4)
def test_bad_assignments(self):
# XXX testing of T_UINT and T_ULONG temporarily disabled;
@@ -91,7 +98,6 @@ class ReadWriteTests(unittest.TestCase):
'T_LONG', 'T_ULONG',
'T_PYSSIZET'
]
-
if hasattr(ts, 'T_LONGLONG'):
integer_attributes.extend(['T_LONGLONG', 'T_ULONGLONG'])
@@ -101,6 +107,11 @@ class ReadWriteTests(unittest.TestCase):
for attr in integer_attributes:
self.assertRaises(TypeError, setattr, ts, attr, nonint)
+ def test_inplace_string(self):
+ self.assertEquals(ts.T_STRING_INPLACE, "hi")
+ self.assertRaises(TypeError, setattr, ts, "T_STRING_INPLACE", "s")
+ self.assertRaises(TypeError, delattr, ts, "T_STRING_INPLACE")
+
class TestWarnings(unittest.TestCase):