diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-04-03 01:46:38 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-04-03 01:46:38 (GMT) |
commit | bde0c9db80db8abe0489b4f96ff88e06890d8787 (patch) | |
tree | 2ab2e16b333f060708e4b93fd9f83a92ac1ad80c /Lib/test/test_structmembers.py | |
parent | 05609eff8a6d02753b8a177560998034f28efb5d (diff) | |
download | cpython-bde0c9db80db8abe0489b4f96ff88e06890d8787.zip cpython-bde0c9db80db8abe0489b4f96ff88e06890d8787.tar.gz cpython-bde0c9db80db8abe0489b4f96ff88e06890d8787.tar.bz2 |
Merged revisions 79645 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r79645 | benjamin.peterson | 2010-04-02 20:40:24 -0500 (Fri, 02 Apr 2010) | 13 lines
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.py | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py index 93e040c..3679ba2 100644 --- a/Lib/test/test_structmembers.py +++ b/Lib/test/test_structmembers.py @@ -8,17 +8,30 @@ from _testcapi import test_structmembersType, \ import warnings, unittest, sys from test import support -ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8, - 9.99999, 10.1010101010) +ts=test_structmembersType(False, # T_BOOL + 1, # T_BYTE + 2, # T_UBYTE + 3, # T_SHORT + 4, # T_USHORT + 5, # T_INT + 6, # T_UINT + 7, # T_LONG + 8, # T_ULONG + 9.99999,# T_FLOAT + 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 @@ -26,6 +39,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 @@ -33,6 +47,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 @@ -40,6 +55,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 @@ -47,21 +63,26 @@ class ReadWriteTests(unittest.TestCase): ts.T_ULONG = ULONG_MAX self.assertEquals(ts.T_ULONG, ULONG_MAX) - ## 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) - - 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) + @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) + + ## 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_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): |