<s> from io import StringIO <EOL> from test . test_json import PyTest , CTest <EOL> from test . support import bigmemtest , _1G <EOL> class TestDump : <EOL> def test_dump ( self ) : <EOL> sio = StringIO ( ) <EOL> self . json . dump ( { } , sio ) <EOL> self . assertEqual ( sio . getvalue ( ) , '<STR_LIT:{}>' ) <EOL> def test_dumps ( self ) : <EOL> self . assertEqual ( self . dumps ( { } ) , '<STR_LIT:{}>' ) <EOL> def test_encode_truefalse ( self ) : <EOL> self . assertEqual ( self . dumps ( <EOL> { True : False , False : True } , sort_keys = True ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( self . dumps ( <EOL> { <NUM_LIT:2> : <NUM_LIT> , <NUM_LIT> : <NUM_LIT:5> , False : <NUM_LIT:1> , <NUM_LIT:6> : True } , sort_keys = True ) , <EOL> '<STR_LIT>' ) <EOL> def test_encode_mutated ( self ) : <EOL> a = [ object ( ) ] * <NUM_LIT:10> <EOL> def crasher ( obj ) : <EOL> del a [ - <NUM_LIT:1> ] <EOL> self . assertEqual ( self . dumps ( a , default = crasher ) , <EOL> '<STR_LIT>' ) <EOL> class TestPyDump ( TestDump , PyTest ) : pass <EOL> class TestCDump ( TestDump , CTest ) : <EOL> @ bigmemtest ( size = _1G , memuse = <NUM_LIT:1> ) <EOL> def test_large_list ( self , size ) : <EOL> N = int ( <NUM_LIT:30> * <NUM_LIT> * <NUM_LIT> * ( size / _1G ) ) <EOL> l = [ <NUM_LIT:1> ] * N <EOL> encoded = self . dumps ( l ) <EOL> self . assertEqual ( len ( encoded ) , N * <NUM_LIT:3> ) <EOL> self . assertEqual ( encoded [ : <NUM_LIT:1> ] , "<STR_LIT:[>" ) <EOL> self . assertEqual ( encoded [ - <NUM_LIT:2> : ] , "<STR_LIT>" ) <EOL> self . assertEqual ( encoded [ <NUM_LIT:1> : - <NUM_LIT:2> ] , "<STR_LIT>" * ( N - <NUM_LIT:1> ) ) </s>
