<s> import unittest <EOL> import struct <EOL> import sys <EOL> from test import test_support , string_tests <EOL> class StrTest ( <EOL> string_tests . CommonTest , <EOL> string_tests . MixinStrUnicodeUserStringTest , <EOL> string_tests . MixinStrUserStringTest , <EOL> string_tests . MixinStrUnicodeTest , <EOL> ) : <EOL> type2test = str <EOL> def fixtype ( self , obj ) : <EOL> return obj <EOL> def test_formatting ( self ) : <EOL> string_tests . MixinStrUnicodeUserStringTest . test_formatting ( self ) <EOL> self . assertRaises ( OverflowError , '<STR_LIT>' . __mod__ , <NUM_LIT> ) <EOL> def test_conversion ( self ) : <EOL> class Foo0 : <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT:foo>" <EOL> class Foo1 : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:foo>" <EOL> class Foo2 ( object ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:foo>" <EOL> class Foo3 ( object ) : <EOL> def __str__ ( self ) : <EOL> return u"<STR_LIT:foo>" <EOL> class Foo4 ( unicode ) : <EOL> def __str__ ( self ) : <EOL> return u"<STR_LIT:foo>" <EOL> class Foo5 ( str ) : <EOL> def __str__ ( self ) : <EOL> return u"<STR_LIT:foo>" <EOL> class Foo6 ( str ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" <EOL> class Foo7 ( unicode ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" <EOL> class Foo8 ( str ) : <EOL> def __new__ ( cls , content = "<STR_LIT>" ) : <EOL> return str . __new__ ( cls , <NUM_LIT:2> * content ) <EOL> def __str__ ( self ) : <EOL> return self <EOL> class Foo9 ( str ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:string>" <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" <EOL> self . assert_ ( str ( Foo0 ( ) ) . startswith ( "<STR_LIT:<>" ) ) <EOL> self . assertEqual ( str ( Foo1 ( ) ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( str ( Foo2 ( ) ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( str ( Foo3 ( ) ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( str ( Foo4 ( "<STR_LIT:bar>" ) ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( str ( Foo5 ( "<STR_LIT:bar>" ) ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( str ( Foo6 ( "<STR_LIT:bar>" ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( str ( Foo7 ( "<STR_LIT:bar>" ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( str ( Foo8 ( "<STR_LIT:foo>" ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( str ( Foo9 ( "<STR_LIT:foo>" ) ) , "<STR_LIT:string>" ) <EOL> self . assertEqual ( unicode ( Foo9 ( "<STR_LIT:foo>" ) ) , u"<STR_LIT>" ) <EOL> def test_expandtabs_overflows_gracefully ( self ) : <EOL> if sys . maxint > ( <NUM_LIT:1> << <NUM_LIT:32> ) or struct . calcsize ( '<STR_LIT:P>' ) != <NUM_LIT:4> : <EOL> return <EOL> self . assertRaises ( ( OverflowError , MemoryError ) , '<STR_LIT>' . expandtabs , sys . maxint ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( StrTest ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
