Ezio Melotti committed 1538307

#16888: test_array now works with unittest test discovery. Patch by Zachary Ware.

Comments (0)

Files changed (2)


     def __init__(self, typecode, newarg=None):
-tests = [] # list to accumulate all tests
 typecodes = "ubBhHiIlLfd"
 if have_long_long:
     typecodes += 'qQ'
         self.assertRaises(TypeError, array.array, 'xx')
         self.assertRaises(ValueError, array.array, 'x')
 # Machine format codes.
                 msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
-class BaseTest(unittest.TestCase):
+class BaseTest:
     # Required class attributes (provided by subclasses
     # typecode: the typecode to test
     # example: an initializer usable in the constructor for this type
         a = array.array(self.typecode, self.example)
         self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2])
-class UnicodeTest(StringTest):
+class UnicodeTest(StringTest, unittest.TestCase):
     typecode = 'u'
     example = '\x01\u263a\x00\ufeff'
     smallerexample = '\x01\u263a\x00\ufefe'
         self.assertRaises(TypeError, a.fromunicode)
 class NumberTest(BaseTest):
     def test_extslice(self):
-class ByteTest(SignedNumberTest):
+class ByteTest(SignedNumberTest, unittest.TestCase):
     typecode = 'b'
     minitemsize = 1
-class UnsignedByteTest(UnsignedNumberTest):
+class UnsignedByteTest(UnsignedNumberTest, unittest.TestCase):
     typecode = 'B'
     minitemsize = 1
-class ShortTest(SignedNumberTest):
+class ShortTest(SignedNumberTest, unittest.TestCase):
     typecode = 'h'
     minitemsize = 2
-class UnsignedShortTest(UnsignedNumberTest):
+class UnsignedShortTest(UnsignedNumberTest, unittest.TestCase):
     typecode = 'H'
     minitemsize = 2
-class IntTest(SignedNumberTest):
+class IntTest(SignedNumberTest, unittest.TestCase):
     typecode = 'i'
     minitemsize = 2
-class UnsignedIntTest(UnsignedNumberTest):
+class UnsignedIntTest(UnsignedNumberTest, unittest.TestCase):
     typecode = 'I'
     minitemsize = 2
-class LongTest(SignedNumberTest):
+class LongTest(SignedNumberTest, unittest.TestCase):
     typecode = 'l'
     minitemsize = 4
-class UnsignedLongTest(UnsignedNumberTest):
+class UnsignedLongTest(UnsignedNumberTest, unittest.TestCase):
     typecode = 'L'
     minitemsize = 4
 @unittest.skipIf(not have_long_long, 'need long long support')
-class LongLongTest(SignedNumberTest):
+class LongLongTest(SignedNumberTest, unittest.TestCase):
     typecode = 'q'
     minitemsize = 8
 @unittest.skipIf(not have_long_long, 'need long long support')
-class UnsignedLongLongTest(UnsignedNumberTest):
+class UnsignedLongLongTest(UnsignedNumberTest, unittest.TestCase):
     typecode = 'Q'
     minitemsize = 8
 class FPTest(NumberTest):
     example = [-42.0, 0, 42, 1e5, -1e10]
             self.assertEqual(a, b)
-class FloatTest(FPTest):
+class FloatTest(FPTest, unittest.TestCase):
     typecode = 'f'
     minitemsize = 4
-class DoubleTest(FPTest):
+class DoubleTest(FPTest, unittest.TestCase):
     typecode = 'd'
     minitemsize = 8
   "Array of size > maxsize created - MemoryError expected")
-def test_main(verbose=None):
-    import sys
-    support.run_unittest(*tests)
-    # verify reference counting
-    if verbose and hasattr(sys, "gettotalrefcount"):
-        import gc
-        counts = [None] * 5
-        for i in range(len(counts)):
-            support.run_unittest(*tests)
-            gc.collect()
-            counts[i] = sys.gettotalrefcount()
-        print(counts)
 if __name__ == "__main__":
-    test_main(verbose=True)
+    unittest.main()
+- Issue #16888: test_array now works with unittest test discovery.
+  Patch by Zachary Ware.
 - Issue #16896: test_asyncore now works with unittest test discovery.
   Patch by Zachary Ware.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.