<s> """<STR_LIT>""" <EOL> import unittest <EOL> import sys <EOL> import re <EOL> from werkzeug . testsuite import WerkzeugTestCase <EOL> from werkzeug . debug . repr import debug_repr , DebugReprGenerator , dump , helper <EOL> from werkzeug . debug . console import HTMLStringO <EOL> from werkzeug . _compat import PY2 <EOL> class DebugReprTestCase ( WerkzeugTestCase ) : <EOL> def test_basic_repr ( self ) : <EOL> self . assert_equal ( debug_repr ( [ ] ) , u'<STR_LIT>' ) <EOL> self . assert_equal ( debug_repr ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , <EOL> u'<STR_LIT>' ) <EOL> self . assert_equal ( debug_repr ( [ <NUM_LIT:1> , '<STR_LIT:test>' ] ) , <EOL> u'<STR_LIT>' ) <EOL> self . assert_equal ( debug_repr ( [ None ] ) , <EOL> u'<STR_LIT>' ) <EOL> def test_sequence_repr ( self ) : <EOL> self . assert_equal ( debug_repr ( list ( range ( <NUM_LIT:20> ) ) ) , ( <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> ) ) <EOL> def test_mapping_repr ( self ) : <EOL> self . assert_equal ( debug_repr ( { } ) , u'<STR_LIT:{}>' ) <EOL> self . assert_equal ( debug_repr ( { '<STR_LIT:foo>' : <NUM_LIT> } ) , <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' ) <EOL> self . assert_equal ( debug_repr ( dict ( zip ( range ( <NUM_LIT:10> ) , [ None ] * <NUM_LIT:10> ) ) ) , <EOL> u'<STR_LIT>' ) <EOL> self . assert_equal ( <EOL> debug_repr ( ( <NUM_LIT:1> , '<STR_LIT>' , u'<STR_LIT>' ) ) , <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' % ( '<STR_LIT:u>' if PY2 else '<STR_LIT>' ) ) <EOL> def test_custom_repr ( self ) : <EOL> class Foo ( object ) : <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' <EOL> self . assert_equal ( debug_repr ( Foo ( ) ) , <EOL> '<STR_LIT>' ) <EOL> def test_list_subclass_repr ( self ) : <EOL> class MyList ( list ) : <EOL> pass <EOL> self . assert_equal ( <EOL> debug_repr ( MyList ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) , <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' ) <EOL> def test_regex_repr ( self ) : <EOL> self . assert_equal ( debug_repr ( re . compile ( r'<STR_LIT>' ) ) , <EOL> u'<STR_LIT>' ) <EOL> self . assert_equal ( debug_repr ( re . compile ( u'<STR_LIT>' ) ) , <EOL> u'<STR_LIT>' % <EOL> ( '<STR_LIT:u>' if PY2 else '<STR_LIT>' ) ) <EOL> def test_set_repr ( self ) : <EOL> self . assert_equal ( debug_repr ( frozenset ( '<STR_LIT:x>' ) ) , <EOL> u'<STR_LIT>' ) <EOL> self . assert_equal ( debug_repr ( set ( '<STR_LIT:x>' ) ) , <EOL> u'<STR_LIT>' ) <EOL> def test_recursive_repr ( self ) : <EOL> a = [ <NUM_LIT:1> ] <EOL> a . append ( a ) <EOL> self . assert_equal ( debug_repr ( a ) , <EOL> u'<STR_LIT>' ) <EOL> def test_broken_repr ( self ) : <EOL> class Foo ( object ) : <EOL> def __repr__ ( self ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . assert_equal ( <EOL> debug_repr ( Foo ( ) ) , <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' ) <EOL> class Foo ( object ) : <EOL> x = <NUM_LIT> <EOL> y = <NUM_LIT> <EOL> def __init__ ( self ) : <EOL> self . z = <NUM_LIT:15> <EOL> class DebugHelpersTestCase ( WerkzeugTestCase ) : <EOL> def test_object_dumping ( self ) : <EOL> drg = DebugReprGenerator ( ) <EOL> out = drg . dump_object ( Foo ( ) ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> out = drg . dump_object ( { '<STR_LIT:x>' : <NUM_LIT> , '<STR_LIT:y>' : <NUM_LIT> } ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> out = drg . dump_object ( { '<STR_LIT:x>' : <NUM_LIT> , '<STR_LIT:y>' : <NUM_LIT> , <NUM_LIT> : <NUM_LIT:11> } ) <EOL> assert not re . search ( '<STR_LIT>' , out ) <EOL> out = drg . dump_locals ( { '<STR_LIT:x>' : <NUM_LIT> , '<STR_LIT:y>' : <NUM_LIT> } ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> assert re . search ( '<STR_LIT>' , out ) <EOL> def test_debug_dump ( self ) : <EOL> old = sys . stdout <EOL> sys . stdout = HTMLStringO ( ) <EOL> try : <EOL> dump ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> x = sys . stdout . reset ( ) <EOL> dump ( ) <EOL> y = sys . stdout . reset ( ) <EOL> finally : <EOL> sys . stdout = old <EOL> self . assert_in ( '<STR_LIT>' , x ) <EOL> self . assert_in ( '<STR_LIT>' , x ) <EOL> self . assert_in ( '<STR_LIT>' , y ) <EOL> self . assert_in ( '<STR_LIT>' , y ) <EOL> self . assert_in ( '<STR_LIT>' , y ) <EOL> def test_debug_help ( self ) : <EOL> old = sys . stdout <EOL> sys . stdout = HTMLStringO ( ) <EOL> try : <EOL> helper ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> x = sys . stdout . reset ( ) <EOL> finally : <EOL> sys . stdout = old <EOL> self . assert_in ( '<STR_LIT>' , x ) <EOL> self . assert_in ( '<STR_LIT>' , x ) <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . makeSuite ( DebugReprTestCase ) ) <EOL> suite . addTest ( unittest . makeSuite ( DebugHelpersTestCase ) ) <EOL> return suite </s>
