2 from test
import test_support
, string_tests
6 string_tests
.CommonTest
,
7 string_tests
.MixinStrUnicodeUserStringTest
,
8 string_tests
.MixinStrUserStringTest
,
9 string_tests
.MixinStrUnicodeTest
,
14 # We don't need to propagate to str
15 def fixtype(self
, obj
):
18 def test_formatting(self
):
19 string_tests
.MixinStrUnicodeUserStringTest
.test_formatting(self
)
20 self
.assertRaises(OverflowError, '%c'.__mod
__, 0x1234)
22 def test_conversion(self
):
23 # Make sure __str__() behaves properly
25 def __unicode__(self
):
52 def __unicode__(self
):
58 def __unicode__(self
):
62 def __new__(cls
, content
=""):
63 return str.__new
__(cls
, 2*content
)
70 def __unicode__(self
):
73 self
.assert_(str(Foo0()).startswith("<")) # this is different from __unicode__
74 self
.assertEqual(str(Foo1()), "foo")
75 self
.assertEqual(str(Foo2()), "foo")
76 self
.assertEqual(str(Foo3()), "foo")
77 self
.assertEqual(str(Foo4("bar")), "foo")
78 self
.assertEqual(str(Foo5("bar")), "foo")
79 self
.assertEqual(str(Foo6("bar")), "foos")
80 self
.assertEqual(str(Foo7("bar")), "foos")
81 self
.assertEqual(str(Foo8("foo")), "foofoo")
82 self
.assertEqual(str(Foo9("foo")), "string")
83 self
.assertEqual(unicode(Foo9("foo")), u
"not unicode")
86 test_support
.run_unittest(StrTest
)
88 if __name__
== "__main__":