@@ -31,7 +31,6 @@ class ArraySubclassWithKwargs(array.array):
3131 def __init__ (self , typecode , newarg = None ):
3232 array .array .__init__ (self )
3333
34- tests = [] # list to accumulate all tests
3534typecodes = "ubBhHiIlLfd"
3635if have_long_long :
3736 typecodes += 'qQ'
@@ -44,7 +43,6 @@ def test_constructor(self):
4443 self .assertRaises (TypeError , array .array , 'xx' )
4544 self .assertRaises (ValueError , array .array , 'x' )
4645
47- tests .append (BadConstructorTest )
4846
4947# Machine format codes.
5048#
@@ -174,10 +172,7 @@ def test_unicode(self):
174172 msg = "{0!r} != {1!r}; testcase={2!r}" .format (a , b , testcase ))
175173
176174
177- tests .append (ArrayReconstructorTest )
178-
179-
180- class BaseTest (unittest .TestCase ):
175+ class BaseTest :
181176 # Required class attributes (provided by subclasses
182177 # typecode: the typecode to test
183178 # example: an initializer usable in the constructor for this type
@@ -1036,7 +1031,7 @@ def test_setitem(self):
10361031 a = array .array (self .typecode , self .example )
10371032 self .assertRaises (TypeError , a .__setitem__ , 0 , self .example [:2 ])
10381033
1039- class UnicodeTest (StringTest ):
1034+ class UnicodeTest (StringTest , unittest . TestCase ):
10401035 typecode = 'u'
10411036 example = '\x01 \u263a \x00 \ufeff '
10421037 smallerexample = '\x01 \u263a \x00 \ufefe '
@@ -1074,8 +1069,6 @@ def test_unicode(self):
10741069
10751070 self .assertRaises (TypeError , a .fromunicode )
10761071
1077- tests .append (UnicodeTest )
1078-
10791072class NumberTest (BaseTest ):
10801073
10811074 def test_extslice (self ):
@@ -1216,57 +1209,47 @@ def test_bytes_extend(self):
12161209 )
12171210
12181211
1219- class ByteTest (SignedNumberTest ):
1212+ class ByteTest (SignedNumberTest , unittest . TestCase ):
12201213 typecode = 'b'
12211214 minitemsize = 1
1222- tests .append (ByteTest )
12231215
1224- class UnsignedByteTest (UnsignedNumberTest ):
1216+ class UnsignedByteTest (UnsignedNumberTest , unittest . TestCase ):
12251217 typecode = 'B'
12261218 minitemsize = 1
1227- tests .append (UnsignedByteTest )
12281219
1229- class ShortTest (SignedNumberTest ):
1220+ class ShortTest (SignedNumberTest , unittest . TestCase ):
12301221 typecode = 'h'
12311222 minitemsize = 2
1232- tests .append (ShortTest )
12331223
1234- class UnsignedShortTest (UnsignedNumberTest ):
1224+ class UnsignedShortTest (UnsignedNumberTest , unittest . TestCase ):
12351225 typecode = 'H'
12361226 minitemsize = 2
1237- tests .append (UnsignedShortTest )
12381227
1239- class IntTest (SignedNumberTest ):
1228+ class IntTest (SignedNumberTest , unittest . TestCase ):
12401229 typecode = 'i'
12411230 minitemsize = 2
1242- tests .append (IntTest )
12431231
1244- class UnsignedIntTest (UnsignedNumberTest ):
1232+ class UnsignedIntTest (UnsignedNumberTest , unittest . TestCase ):
12451233 typecode = 'I'
12461234 minitemsize = 2
1247- tests .append (UnsignedIntTest )
12481235
1249- class LongTest (SignedNumberTest ):
1236+ class LongTest (SignedNumberTest , unittest . TestCase ):
12501237 typecode = 'l'
12511238 minitemsize = 4
1252- tests .append (LongTest )
12531239
1254- class UnsignedLongTest (UnsignedNumberTest ):
1240+ class UnsignedLongTest (UnsignedNumberTest , unittest . TestCase ):
12551241 typecode = 'L'
12561242 minitemsize = 4
1257- tests .append (UnsignedLongTest )
12581243
12591244@unittest .skipIf (not have_long_long , 'need long long support' )
1260- class LongLongTest (SignedNumberTest ):
1245+ class LongLongTest (SignedNumberTest , unittest . TestCase ):
12611246 typecode = 'q'
12621247 minitemsize = 8
1263- tests .append (LongLongTest )
12641248
12651249@unittest .skipIf (not have_long_long , 'need long long support' )
1266- class UnsignedLongLongTest (UnsignedNumberTest ):
1250+ class UnsignedLongLongTest (UnsignedNumberTest , unittest . TestCase ):
12671251 typecode = 'Q'
12681252 minitemsize = 8
1269- tests .append (UnsignedLongLongTest )
12701253
12711254class FPTest (NumberTest ):
12721255 example = [- 42.0 , 0 , 42 , 1e5 , - 1e10 ]
@@ -1293,12 +1276,11 @@ def test_byteswap(self):
12931276 b .byteswap ()
12941277 self .assertEqual (a , b )
12951278
1296- class FloatTest (FPTest ):
1279+ class FloatTest (FPTest , unittest . TestCase ):
12971280 typecode = 'f'
12981281 minitemsize = 4
1299- tests .append (FloatTest )
13001282
1301- class DoubleTest (FPTest ):
1283+ class DoubleTest (FPTest , unittest . TestCase ):
13021284 typecode = 'd'
13031285 minitemsize = 8
13041286
@@ -1319,22 +1301,6 @@ def test_alloc_overflow(self):
13191301 else :
13201302 self .fail ("Array of size > maxsize created - MemoryError expected" )
13211303
1322- tests .append (DoubleTest )
1323-
1324- def test_main (verbose = None ):
1325- import sys
1326-
1327- support .run_unittest (* tests )
1328-
1329- # verify reference counting
1330- if verbose and hasattr (sys , "gettotalrefcount" ):
1331- import gc
1332- counts = [None ] * 5
1333- for i in range (len (counts )):
1334- support .run_unittest (* tests )
1335- gc .collect ()
1336- counts [i ] = sys .gettotalrefcount ()
1337- print (counts )
13381304
13391305if __name__ == "__main__" :
1340- test_main ( verbose = True )
1306+ unittest . main ( )
0 commit comments