Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_structmembers.py

    r2 r391  
    1 from _testcapi import test_structmembersType, \
     1from _testcapi import _test_structmembersType, \
    22    CHAR_MAX, CHAR_MIN, UCHAR_MAX, \
    33    SHRT_MAX, SHRT_MIN, USHRT_MAX, \
     
    66    LLONG_MAX, LLONG_MIN, ULLONG_MAX
    77
    8 import warnings, exceptions, unittest, sys
     8import unittest
    99from test import test_support
    1010
    11 ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
    12                           9.99999, 10.1010101010)
     11ts=_test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
     12                          9.99999, 10.1010101010, "hi")
    1313
    1414class ReadWriteTests(unittest.TestCase):
    15     def test_types(self):
     15
     16    def test_bool(self):
    1617        ts.T_BOOL = True
    17         self.assertEquals(ts.T_BOOL, True)
     18        self.assertEqual(ts.T_BOOL, True)
    1819        ts.T_BOOL = False
    19         self.assertEquals(ts.T_BOOL, False)
     20        self.assertEqual(ts.T_BOOL, False)
    2021        self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
    2122
     23    def test_byte(self):
    2224        ts.T_BYTE = CHAR_MAX
    23         self.assertEquals(ts.T_BYTE, CHAR_MAX)
     25        self.assertEqual(ts.T_BYTE, CHAR_MAX)
    2426        ts.T_BYTE = CHAR_MIN
    25         self.assertEquals(ts.T_BYTE, CHAR_MIN)
     27        self.assertEqual(ts.T_BYTE, CHAR_MIN)
    2628        ts.T_UBYTE = UCHAR_MAX
    27         self.assertEquals(ts.T_UBYTE, UCHAR_MAX)
     29        self.assertEqual(ts.T_UBYTE, UCHAR_MAX)
    2830
     31    def test_short(self):
    2932        ts.T_SHORT = SHRT_MAX
    30         self.assertEquals(ts.T_SHORT, SHRT_MAX)
     33        self.assertEqual(ts.T_SHORT, SHRT_MAX)
    3134        ts.T_SHORT = SHRT_MIN
    32         self.assertEquals(ts.T_SHORT, SHRT_MIN)
     35        self.assertEqual(ts.T_SHORT, SHRT_MIN)
    3336        ts.T_USHORT = USHRT_MAX
    34         self.assertEquals(ts.T_USHORT, USHRT_MAX)
     37        self.assertEqual(ts.T_USHORT, USHRT_MAX)
    3538
     39    def test_int(self):
    3640        ts.T_INT = INT_MAX
    37         self.assertEquals(ts.T_INT, INT_MAX)
     41        self.assertEqual(ts.T_INT, INT_MAX)
    3842        ts.T_INT = INT_MIN
    39         self.assertEquals(ts.T_INT, INT_MIN)
     43        self.assertEqual(ts.T_INT, INT_MIN)
    4044        ts.T_UINT = UINT_MAX
    41         self.assertEquals(ts.T_UINT, UINT_MAX)
     45        self.assertEqual(ts.T_UINT, UINT_MAX)
    4246
     47    def test_long(self):
    4348        ts.T_LONG = LONG_MAX
    44         self.assertEquals(ts.T_LONG, LONG_MAX)
     49        self.assertEqual(ts.T_LONG, LONG_MAX)
    4550        ts.T_LONG = LONG_MIN
    46         self.assertEquals(ts.T_LONG, LONG_MIN)
     51        self.assertEqual(ts.T_LONG, LONG_MIN)
    4752        ts.T_ULONG = ULONG_MAX
    48         self.assertEquals(ts.T_ULONG, ULONG_MAX)
     53        self.assertEqual(ts.T_ULONG, ULONG_MAX)
    4954
    50         ## T_LONGLONG and T_ULONGLONG may not be present on some platforms
    51         if hasattr(ts, 'T_LONGLONG'):
    52             ts.T_LONGLONG = LLONG_MAX
    53             self.assertEquals(ts.T_LONGLONG, LLONG_MAX)
    54             ts.T_LONGLONG = LLONG_MIN
    55             self.assertEquals(ts.T_LONGLONG, LLONG_MIN)
     55    @unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present")
     56    def test_longlong(self):
     57        ts.T_LONGLONG = LLONG_MAX
     58        self.assertEqual(ts.T_LONGLONG, LLONG_MAX)
     59        ts.T_LONGLONG = LLONG_MIN
     60        self.assertEqual(ts.T_LONGLONG, LLONG_MIN)
    5661
    57             ts.T_ULONGLONG = ULLONG_MAX
    58             self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX)
     62        ts.T_ULONGLONG = ULLONG_MAX
     63        self.assertEqual(ts.T_ULONGLONG, ULLONG_MAX)
    5964
    60             ## make sure these will accept a plain int as well as a long
    61             ts.T_LONGLONG = 3
    62             self.assertEquals(ts.T_LONGLONG, 3)
    63             ts.T_ULONGLONG = 4
    64             self.assertEquals(ts.T_ULONGLONG, 4)
     65        ## make sure these will accept a plain int as well as a long
     66        ts.T_LONGLONG = 3
     67        self.assertEqual(ts.T_LONGLONG, 3)
     68        ts.T_ULONGLONG = 4
     69        self.assertEqual(ts.T_ULONGLONG, 4)
     70
     71    def test_inplace_string(self):
     72        self.assertEqual(ts.T_STRING_INPLACE, "hi")
     73        self.assertRaises(TypeError, setattr, ts, "T_STRING_INPLACE", "s")
     74        self.assertRaises(TypeError, delattr, ts, "T_STRING_INPLACE")
    6575
    6676
    6777class TestWarnings(unittest.TestCase):
    68     def has_warned(self, w):
    69         self.assertEqual(w.category, RuntimeWarning)
    7078
    7179    def test_byte_max(self):
    72         with test_support.check_warnings() as w:
     80        with test_support.check_warnings(('', RuntimeWarning)):
    7381            ts.T_BYTE = CHAR_MAX+1
    74             self.has_warned(w)
    7582
    7683    def test_byte_min(self):
    77         with test_support.check_warnings() as w:
     84        with test_support.check_warnings(('', RuntimeWarning)):
    7885            ts.T_BYTE = CHAR_MIN-1
    79             self.has_warned(w)
    8086
    8187    def test_ubyte_max(self):
    82         with test_support.check_warnings() as w:
     88        with test_support.check_warnings(('', RuntimeWarning)):
    8389            ts.T_UBYTE = UCHAR_MAX+1
    84             self.has_warned(w)
    8590
    8691    def test_short_max(self):
    87         with test_support.check_warnings() as w:
     92        with test_support.check_warnings(('', RuntimeWarning)):
    8893            ts.T_SHORT = SHRT_MAX+1
    89             self.has_warned(w)
    9094
    9195    def test_short_min(self):
    92         with test_support.check_warnings() as w:
     96        with test_support.check_warnings(('', RuntimeWarning)):
    9397            ts.T_SHORT = SHRT_MIN-1
    94             self.has_warned(w)
    9598
    9699    def test_ushort_max(self):
    97         with test_support.check_warnings() as w:
     100        with test_support.check_warnings(('', RuntimeWarning)):
    98101            ts.T_USHORT = USHRT_MAX+1
    99             self.has_warned(w)
    100 
    101102
    102103
Note: See TracChangeset for help on using the changeset viewer.