]> granicus.if.org Git - python/commitdiff
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
authorWalter Dörwald <walter@livinglogic.de>
Thu, 26 Aug 2004 16:53:04 +0000 (16:53 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Thu, 26 Aug 2004 16:53:04 +0000 (16:53 +0000)
it can be used for str and unicode. Drop the test for
   "".join([s]) is s
because this is an implementation detail (and doesn't work for unicode)

Lib/test/string_tests.py
Lib/test/test_str.py
Lib/test/test_string.py
Lib/test/test_unicode.py

index 860c1f2f83a965a6862fdce664f148794fc2c39d..9cf6b9e1cfa530a86fa6149d0b28bbb94f02d26c 100644 (file)
@@ -648,6 +648,7 @@ class MixinStrUnicodeUserStringTest:
                 else:
                     self.checkcall(format, "__mod__", value)
 
+
 class MixinStrStringUserStringTest:
     # Additional tests for 8bit strings, i.e. str, UserString and
     # the string module
@@ -695,3 +696,21 @@ class MixinStrUserStringTest:
 
         self.checkraises(TypeError, 'xyz', 'decode', 42)
         self.checkraises(TypeError, 'xyz', 'encode', 42)
+
+
+class MixinStrUnicodeTest:
+    # Additional tests that only work with
+    # str and unicode
+
+    def test_bug1001011(self):
+        # Make sure join returns a NEW object for single item sequences
+        # involving a subclass
+        # Make sure that it is of the appropriate type
+        # Check the optimisation still occurs for standard objects
+        t = self.type2test
+        class subclass(t):
+            pass
+        s1 = subclass("abcd")
+        s2 = t().join([s1])
+        self.assert_(s1 is not s2)
+        self.assert_(type(s2) is t)
index 1295a8ca367cd6c2145f2def75796cb887cf6695..82632f10ebb86c86f4c20b21be5de1c90fc45a4d 100644 (file)
@@ -5,7 +5,8 @@ from test import test_support, string_tests
 class StrTest(
     string_tests.CommonTest,
     string_tests.MixinStrUnicodeUserStringTest,
-    string_tests.MixinStrUserStringTest
+    string_tests.MixinStrUserStringTest,
+    string_tests.MixinStrUnicodeTest,
     ):
 
     type2test = str
index ba9d9d397232b6114ae41cd29a811eb27bb1ba62..d80c3b60436d00b4dda91d6bb104d1648501f687 100644 (file)
@@ -52,28 +52,6 @@ class StringTest(
         self.checkraises(TypeError, string_tests.BadSeq1(), 'join', ' ')
         self.checkequal('a b c', string_tests.BadSeq2(), 'join', ' ')
 
-    def test_bug1001011(self):
-        # Make sure join returns a NEW object for single item sequences
-        # involving a subclass
-        # Make sure that it is of the appropriate type
-        # Check the optimisation still occurs for standard objects
-        class str_subclass(str): pass
-        s1 = str_subclass('abcd')
-        s2 = ''.join([s1])
-        self.failIf(s1 is s2)
-        self.assertEqual(type(s2), type(''))
-        s3 = 'abcd'
-        s4 = ''.join([s3])
-        self.failUnless(s3 is s4)
-        if test_support.have_unicode:
-            class unicode_subclass(unicode): pass
-            u1 = unicode_subclass(u'abcd')
-            u2 = ''.join([u1])
-            self.failIf(u1 is u2)
-            self.assertEqual(type(u2), type(u''))
-            u3 = u'abcd'
-            u4 = ''.join([u3])
-            self.failUnless(u3 is u4)
 
 class ModuleTest(unittest.TestCase):
 
index 215c9683b61a53f8fbb379653a9577281e01d748..69244f0d6f3d8c6102b0c5a8cf4528debddb9fc3 100644 (file)
@@ -11,7 +11,8 @@ from test import test_support, string_tests
 
 class UnicodeTest(
     string_tests.CommonTest,
-    string_tests.MixinStrUnicodeUserStringTest
+    string_tests.MixinStrUnicodeUserStringTest,
+    string_tests.MixinStrUnicodeTest,
     ):
     type2test = unicode