Commits

Ezio Melotti committed 5538391

#16910: test_bytes, test_unicode, and test_userstring now work with unittest test discovery. Patch by Zachary Ware.

Comments (0)

Files changed (5)

Lib/test/string_tests.py

     def __init__(self): self.seq = ['a', 'b', 'c']
     def __len__(self): return 8
 
-class BaseTest(unittest.TestCase):
+class BaseTest:
     # These tests are for buffers of values (bytes) and not
     # specific to character interpretation, used for bytes objects
     # and various string implementations

Lib/test/test_bytes.py

         return self.value
 
 
-class BaseBytesTest(unittest.TestCase):
+class BaseBytesTest:
 
     def test_basics(self):
         b = self.type2test()
                                 x, None, None, None)
 
 
-class BytesTest(BaseBytesTest):
+class BytesTest(BaseBytesTest, unittest.TestCase):
     type2test = bytes
 
     def test_buffer_is_readonly(self):
                          b's:cstr')
 
 
-class ByteArrayTest(BaseBytesTest):
+class ByteArrayTest(BaseBytesTest, unittest.TestCase):
     type2test = bytearray
 
     def test_nohash(self):
     def test_lower(self):
         pass
 
-class ByteArrayAsStringTest(FixedStringTest):
+class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase):
     type2test = bytearray
     contains_bytes = True
 
-class BytesAsStringTest(FixedStringTest):
+class BytesAsStringTest(FixedStringTest, unittest.TestCase):
     type2test = bytes
     contains_bytes = True
 
 
-class SubclassTest(unittest.TestCase):
+class SubclassTest:
 
     def test_basic(self):
         self.assertTrue(issubclass(self.subclass2test, self.type2test))
 class BytesSubclass(bytes):
     pass
 
-class ByteArraySubclassTest(SubclassTest):
+class ByteArraySubclassTest(SubclassTest, unittest.TestCase):
     type2test = bytearray
     subclass2test = ByteArraySubclass
 
         self.assertEqual(x, b"abcd")
 
 
-class BytesSubclassTest(SubclassTest):
+class BytesSubclassTest(SubclassTest, unittest.TestCase):
     type2test = bytes
     subclass2test = BytesSubclass
 
 
-def test_main():
-    test.support.run_unittest(
-        BytesTest, AssortedBytesTest, BytesAsStringTest,
-        ByteArrayTest, ByteArrayAsStringTest, BytesSubclassTest,
-        ByteArraySubclassTest, BytearrayPEP3137Test)
-
 if __name__ == "__main__":
-    test_main()
+    unittest.main()

Lib/test/test_unicode.py

 
 class UnicodeTest(string_tests.CommonTest,
         string_tests.MixinStrUnicodeUserStringTest,
-        string_tests.MixinStrUnicodeTest):
+        string_tests.MixinStrUnicodeTest,
+        unittest.TestCase):
 
     type2test = str
 
         self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
 
 
-def test_main():
-    support.run_unittest(__name__)
-
 if __name__ == "__main__":
-    test_main()
+    unittest.main()

Lib/test/test_userstring.py

 # UserString instances should behave similar to builtin string objects.
 
 import string
+import unittest
 from test import support, string_tests
 
 from collections import UserString
 class UserStringTest(
     string_tests.CommonTest,
     string_tests.MixinStrUnicodeUserStringTest,
+    unittest.TestCase
     ):
 
     type2test = UserString
         getattr(object, methodname)(*args)
 
 
-def test_main():
-    support.run_unittest(UserStringTest)
-
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
 Tests
 -----
 
+- Issue #16910: test_bytes, test_unicode, and test_userstring now work with
+  unittest test discovery.  Patch by Zachary Ware.
+
 - Issue #16905: test_warnings now works with unittest test discovery.
   Initial patch by Berker Peksag.