[Python-checkins] python/dist/src/Lib/test string_tests.py, 1.39,
1.40 test_str.py, 1.3, 1.4 test_string.py, 1.26,
1.27 test_unicode.py, 1.92, 1.93
doerwalter at users.sourceforge.net
doerwalter at users.sourceforge.net
Thu Aug 26 18:53:07 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9674/Lib/test
Modified Files:
string_tests.py test_str.py test_string.py test_unicode.py
Log Message:
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
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)
Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- string_tests.py 4 Aug 2004 07:38:33 -0000 1.39
+++ string_tests.py 26 Aug 2004 16:53:04 -0000 1.40
@@ -648,6 +648,7 @@
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 @@
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: test_str.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_str.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test_str.py 1 May 2003 17:45:50 -0000 1.3
+++ test_str.py 26 Aug 2004 16:53:04 -0000 1.4
@@ -5,7 +5,8 @@
class StrTest(
string_tests.CommonTest,
string_tests.MixinStrUnicodeUserStringTest,
- string_tests.MixinStrUserStringTest
+ string_tests.MixinStrUserStringTest,
+ string_tests.MixinStrUnicodeTest,
):
type2test = str
Index: test_string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- test_string.py 23 Aug 2004 23:23:53 -0000 1.26
+++ test_string.py 26 Aug 2004 16:53:04 -0000 1.27
@@ -52,28 +52,6 @@
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: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- test_unicode.py 4 Aug 2004 07:38:33 -0000 1.92
+++ test_unicode.py 26 Aug 2004 16:53:04 -0000 1.93
@@ -11,7 +11,8 @@
class UnicodeTest(
string_tests.CommonTest,
- string_tests.MixinStrUnicodeUserStringTest
+ string_tests.MixinStrUnicodeUserStringTest,
+ string_tests.MixinStrUnicodeTest,
):
type2test = unicode
More information about the Python-checkins
mailing list