#NEWLINE# def test_encode_json_packet( self ) : #NEWLINE# #INDENT# pkt = packet . Packet ( packet . MESSAGE , data = { #NEWLINE# #INDENT# 'a' : 123 , #NEWLINE# 'b' : '456' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( self . packet_type , packet . MESSAGE ) #NEWLINE# self . assertEqual ( pkt . data , { #NEWLINE# #INDENT# 'a' : 123 , #NEWLINE# 'b' : '456' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertFalse ( pkt . binary ) #NEWLINE# self . assertIn ( pkt . encode ( ) , [ b'4{"a":123,"b":"456"}' , b'4{"b":"456","a":123}' ] )