<s> """<STR_LIT>""" <EOL> import unittest <EOL> import pyamf . xml <EOL> from pyamf import util <EOL> class ElementTreeTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> xml = '<STR_LIT>' <EOL> def check_amf0 ( self , bytes , xml ) : <EOL> b = util . BufferedByteStream ( bytes ) <EOL> self . assertEqual ( b . read_char ( ) , <NUM_LIT:15> ) <EOL> l = b . read_ulong ( ) <EOL> self . assertEqual ( l , b . remaining ( ) ) <EOL> self . assertEqual ( b . read ( ) , xml ) <EOL> def check_amf3 ( self , bytes , xml ) : <EOL> b = util . BufferedByteStream ( bytes ) <EOL> self . assertEqual ( b . read_char ( ) , <NUM_LIT:11> ) <EOL> l = b . read_uchar ( ) <EOL> self . assertEqual ( l >> <NUM_LIT:1> , b . remaining ( ) ) <EOL> self . assertEqual ( b . read ( ) , xml ) <EOL> for mod in pyamf . xml . ETREE_MODULES : <EOL> name = '<STR_LIT>' + mod . replace ( '<STR_LIT:.>' , '<STR_LIT:_>' ) <EOL> def check_etree ( self ) : <EOL> import inspect <EOL> mod = inspect . stack ( ) [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . f_locals [ '<STR_LIT>' ] . __name__ [ <NUM_LIT:5> : ] <EOL> mod = mod . replace ( '<STR_LIT:_>' , '<STR_LIT:.>' ) <EOL> try : <EOL> etree = util . get_module ( mod ) <EOL> except ImportError : <EOL> self . skipTest ( '<STR_LIT>' % ( mod , ) ) <EOL> element = etree . fromstring ( self . xml ) <EOL> xml = etree . tostring ( element ) <EOL> old = pyamf . set_default_etree ( etree ) <EOL> if old : <EOL> self . addCleanup ( lambda x : pyamf . set_default_etree ( x ) , old ) <EOL> bytes = pyamf . encode ( element , encoding = pyamf . AMF0 ) . getvalue ( ) <EOL> self . check_amf0 ( bytes , xml ) <EOL> new_element = pyamf . decode ( bytes , encoding = pyamf . AMF0 ) . next ( ) <EOL> self . assertIdentical ( type ( element ) , type ( new_element ) ) <EOL> bytes = pyamf . encode ( element , encoding = pyamf . AMF3 ) . getvalue ( ) <EOL> self . check_amf3 ( bytes , xml ) <EOL> new_element = pyamf . decode ( bytes , encoding = pyamf . AMF3 ) . next ( ) <EOL> self . assertIdentical ( type ( element ) , type ( new_element ) ) <EOL> check_etree . __name__ = name <EOL> setattr ( ElementTreeTestCase , name , check_etree ) </s>
