mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00

svn+ssh://pythondev@svn.python.org/python/trunk ........ r62350 | nick.coghlan | 2008-04-15 12:25:31 +0200 (Tue, 15 Apr 2008) | 1 line Issue 2439: add pkgutils.get_data() as a convenience wrapper for the PEP 302 get_data() API (contributed by Paul Moore) ........ r62351 | nick.coghlan | 2008-04-15 12:28:14 +0200 (Tue, 15 Apr 2008) | 1 line Add test file missing from rev 62350 ........ r62352 | benjamin.peterson | 2008-04-15 13:58:46 +0200 (Tue, 15 Apr 2008) | 2 lines Add myself to Doc/ACKS.txt ........ r62353 | andrew.kuchling | 2008-04-15 15:10:07 +0200 (Tue, 15 Apr 2008) | 6 lines Add *,**,@ to index, as suggested by http://farmdev.com/thoughts/24/what-does-the-def-star-variable-or-def-asterisk-parameter-syntax-do-in-python-/ The right entry type to use isn't clear; operator seems wrong, because *,**,@ aren't being used in expressions here. I put them as 'statement'; 'syntax' might be better. ........ r62354 | andrew.kuchling | 2008-04-15 15:10:41 +0200 (Tue, 15 Apr 2008) | 1 line Typo fix ........ r62355 | mark.dickinson | 2008-04-15 22:51:18 +0200 (Tue, 15 Apr 2008) | 3 lines Fix for possible signed overflow: the behaviour of -LONG_MIN is undefined in ANSI C. ........ r62358 | jeroen.ruigrok | 2008-04-16 14:47:01 +0200 (Wed, 16 Apr 2008) | 2 lines Reformat to 80 columns prior to adding documentation. ........ r62359 | jeroen.ruigrok | 2008-04-16 14:57:43 +0200 (Wed, 16 Apr 2008) | 2 lines Add details about the return value for mmap.flush(). ........ r62364 | raymond.hettinger | 2008-04-17 12:48:31 +0200 (Thu, 17 Apr 2008) | 1 line Issue 2648: Add leading zero to money format recipe in the docs. ........ r62365 | jeroen.ruigrok | 2008-04-17 14:39:45 +0200 (Thu, 17 Apr 2008) | 2 lines Be consistent in the use of read-only. ........ r62370 | andrew.kuchling | 2008-04-17 22:44:06 +0200 (Thu, 17 Apr 2008) | 1 line Typo fixes ........ r62372 | andrew.kuchling | 2008-04-18 04:40:47 +0200 (Fri, 18 Apr 2008) | 1 line Use correct parameter name ........ r62373 | andrew.kuchling | 2008-04-18 18:53:09 +0200 (Fri, 18 Apr 2008) | 1 line #2654: fix typo ........ r62374 | andrew.kuchling | 2008-04-18 20:28:23 +0200 (Fri, 18 Apr 2008) | 4 lines Remove personal note from Jim Roskind; it no longer applies, and the e-mail address is for a previous employer. Can we move the big long copyright statement into a sidebar or something? ........ r62375 | andrew.kuchling | 2008-04-18 20:39:55 +0200 (Fri, 18 Apr 2008) | 1 line Rewrite introductory section, and remove old section. (It was already commented-out, but why keep it?) ........ r62378 | skip.montanaro | 2008-04-18 22:35:46 +0200 (Fri, 18 Apr 2008) | 1 line resolve issue 2014 ........ r62379 | benjamin.peterson | 2008-04-18 22:45:33 +0200 (Fri, 18 Apr 2008) | 2 lines Fix indentation in sysmodule.c ........ r62381 | amaury.forgeotdarc | 2008-04-19 01:31:33 +0200 (Sat, 19 Apr 2008) | 3 lines Some tests did not pass on repeated calls (regrtest -R::) Perform additional cleanup, mostly deleting from sys.modules, or clearing the warnings registry. ........
107 lines
3.3 KiB
Python
107 lines
3.3 KiB
Python
from _testcapi import test_structmembersType, \
|
|
CHAR_MAX, CHAR_MIN, UCHAR_MAX, \
|
|
SHRT_MAX, SHRT_MIN, USHRT_MAX, \
|
|
INT_MAX, INT_MIN, UINT_MAX, \
|
|
LONG_MAX, LONG_MIN, ULONG_MAX, \
|
|
LLONG_MAX, LLONG_MIN, ULLONG_MAX
|
|
|
|
import warnings, unittest, sys
|
|
from test import test_support
|
|
|
|
ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
|
|
9.99999, 10.1010101010)
|
|
|
|
class ReadWriteTests(unittest.TestCase):
|
|
def test_types(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)
|
|
|
|
ts.T_BYTE = CHAR_MAX
|
|
self.assertEquals(ts.T_BYTE, CHAR_MAX)
|
|
ts.T_BYTE = CHAR_MIN
|
|
self.assertEquals(ts.T_BYTE, CHAR_MIN)
|
|
ts.T_UBYTE = UCHAR_MAX
|
|
self.assertEquals(ts.T_UBYTE, UCHAR_MAX)
|
|
|
|
ts.T_SHORT = SHRT_MAX
|
|
self.assertEquals(ts.T_SHORT, SHRT_MAX)
|
|
ts.T_SHORT = SHRT_MIN
|
|
self.assertEquals(ts.T_SHORT, SHRT_MIN)
|
|
ts.T_USHORT = USHRT_MAX
|
|
self.assertEquals(ts.T_USHORT, USHRT_MAX)
|
|
|
|
ts.T_INT = INT_MAX
|
|
self.assertEquals(ts.T_INT, INT_MAX)
|
|
ts.T_INT = INT_MIN
|
|
self.assertEquals(ts.T_INT, INT_MIN)
|
|
ts.T_UINT = UINT_MAX
|
|
self.assertEquals(ts.T_UINT, UINT_MAX)
|
|
|
|
ts.T_LONG = LONG_MAX
|
|
self.assertEquals(ts.T_LONG, LONG_MAX)
|
|
ts.T_LONG = LONG_MIN
|
|
self.assertEquals(ts.T_LONG, LONG_MIN)
|
|
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)
|
|
|
|
|
|
class TestWarnings(unittest.TestCase):
|
|
def has_warned(self, w):
|
|
self.assertEqual(w.category, RuntimeWarning)
|
|
|
|
def test_byte_max(self):
|
|
with test_support.catch_warning() as w:
|
|
ts.T_BYTE = CHAR_MAX+1
|
|
self.has_warned(w)
|
|
|
|
def test_byte_min(self):
|
|
with test_support.catch_warning() as w:
|
|
ts.T_BYTE = CHAR_MIN-1
|
|
self.has_warned(w)
|
|
|
|
def test_ubyte_max(self):
|
|
with test_support.catch_warning() as w:
|
|
ts.T_UBYTE = UCHAR_MAX+1
|
|
self.has_warned(w)
|
|
|
|
def test_short_max(self):
|
|
with test_support.catch_warning() as w:
|
|
ts.T_SHORT = SHRT_MAX+1
|
|
self.has_warned(w)
|
|
|
|
def test_short_min(self):
|
|
with test_support.catch_warning() as w:
|
|
ts.T_SHORT = SHRT_MIN-1
|
|
self.has_warned(w)
|
|
|
|
def test_ushort_max(self):
|
|
with test_support.catch_warning() as w:
|
|
ts.T_USHORT = USHRT_MAX+1
|
|
self.has_warned(w)
|
|
|
|
|
|
|
|
def test_main(verbose=None):
|
|
test_support.run_unittest(__name__)
|
|
|
|
if __name__ == "__main__":
|
|
test_main(verbose=True)
|