summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-01-10 05:46:29 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-01-10 05:46:29 (GMT)
commit5b1acc0dff9b242cc6e5f7c7aa1a19f361f98004 (patch)
tree780c90cc38575904d739069ad11c3b04db4b756c
parent47b988609f5669ed2788a3c5c6004b13a3c2cff0 (diff)
parent0dceb560b6b7bfc0a2e11d3a6c27f0a7c7e2e619 (diff)
downloadcpython-5b1acc0dff9b242cc6e5f7c7aa1a19f361f98004.zip
cpython-5b1acc0dff9b242cc6e5f7c7aa1a19f361f98004.tar.gz
cpython-5b1acc0dff9b242cc6e5f7c7aa1a19f361f98004.tar.bz2
#16910: merge with 3.3.
-rw-r--r--Lib/test/string_tests.py2
-rw-r--r--Lib/test/test_bytes.py24
-rw-r--r--Lib/test/test_unicode.py8
-rwxr-xr-xLib/test/test_userstring.py7
-rw-r--r--Misc/NEWS3
5 files changed, 19 insertions, 25 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index e4688d0..27e4662 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -19,7 +19,7 @@ class BadSeq2(Sequence):
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
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 0a6d446..acf9daf 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -38,7 +38,7 @@ class Indexable:
return self.value
-class BaseBytesTest(unittest.TestCase):
+class BaseBytesTest:
def test_basics(self):
b = self.type2test()
@@ -696,7 +696,7 @@ class BaseBytesTest(unittest.TestCase):
x, None, None, None)
-class BytesTest(BaseBytesTest):
+class BytesTest(BaseBytesTest, unittest.TestCase):
type2test = bytes
def test_buffer_is_readonly(self):
@@ -744,7 +744,7 @@ class BytesTest(BaseBytesTest):
b's:cstr')
-class ByteArrayTest(BaseBytesTest):
+class ByteArrayTest(BaseBytesTest, unittest.TestCase):
type2test = bytearray
def test_nohash(self):
@@ -1312,16 +1312,16 @@ class FixedStringTest(test.string_tests.BaseTest):
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))
@@ -1393,7 +1393,7 @@ class ByteArraySubclass(bytearray):
class BytesSubclass(bytes):
pass
-class ByteArraySubclassTest(SubclassTest):
+class ByteArraySubclassTest(SubclassTest, unittest.TestCase):
type2test = bytearray
subclass2test = ByteArraySubclass
@@ -1408,16 +1408,10 @@ class ByteArraySubclassTest(SubclassTest):
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()
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 058c83a..2d42aac 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -33,7 +33,8 @@ codecs.register(search_function)
class UnicodeTest(string_tests.CommonTest,
string_tests.MixinStrUnicodeUserStringTest,
- string_tests.MixinStrUnicodeTest):
+ string_tests.MixinStrUnicodeTest,
+ unittest.TestCase):
type2test = str
@@ -2242,8 +2243,5 @@ class StringModuleTest(unittest.TestCase):
self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
-def test_main():
- support.run_unittest(__name__)
-
if __name__ == "__main__":
- test_main()
+ unittest.main()
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index d5d0c89..71fcac2 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -3,6 +3,7 @@
# UserString instances should behave similar to builtin string objects.
import string
+import unittest
from test import support, string_tests
from collections import UserString
@@ -10,6 +11,7 @@ from collections import UserString
class UserStringTest(
string_tests.CommonTest,
string_tests.MixinStrUnicodeUserStringTest,
+ unittest.TestCase
):
type2test = UserString
@@ -42,8 +44,5 @@ class UserStringTest(
getattr(object, methodname)(*args)
-def test_main():
- support.run_unittest(UserStringTest)
-
if __name__ == "__main__":
- test_main()
+ unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
index 76ae11e..926a15b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -614,6 +614,9 @@ Tests
- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host.
+- 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.