<s> import steel <EOL> import unittest <EOL> class NameAwareOrderedDictTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . d = steel . NameAwareOrderedDict ( ) <EOL> def test_ignore_object ( self ) : <EOL> self . d [ '<STR_LIT>' ] = object ( ) <EOL> self . assertFalse ( hasattr ( self . d [ '<STR_LIT>' ] , '<STR_LIT:name>' ) ) <EOL> def test_auto_name ( self ) : <EOL> class NamedObject : <EOL> def set_name ( self , name ) : <EOL> self . name = name <EOL> self . d [ '<STR_LIT>' ] = NamedObject ( ) <EOL> self . assertEqual ( self . d [ '<STR_LIT>' ] . name , '<STR_LIT>' ) <EOL> def test_errors ( self ) : <EOL> class ErrorObject : <EOL> "<STR_LIT>" <EOL> def set_name ( self , name ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> with self . assertRaises ( TypeError ) : <EOL> self . d [ '<STR_LIT>' ] = ErrorObject ( ) <EOL> class SizeTests ( unittest . TestCase ) : <EOL> def test_explicit_sizes ( self ) : <EOL> class Test ( steel . Structure ) : <EOL> field1 = steel . Bytes ( size = <NUM_LIT:2> ) <EOL> field2 = steel . Bytes ( size = <NUM_LIT:4> ) <EOL> self . assertEqual ( Test . size , <NUM_LIT:6> ) <EOL> class InstantiationTests ( unittest . TestCase ) : <EOL> def test_empty_args ( self ) : <EOL> class Test ( steel . Structure ) : <EOL> field1 = steel . Bytes ( size = <NUM_LIT:2> ) <EOL> field2 = steel . Bytes ( size = <NUM_LIT:4> ) <EOL> obj = Test ( ) <EOL> self . assertNotIn ( '<STR_LIT>' , obj . __dict__ ) <EOL> self . assertNotIn ( '<STR_LIT>' , obj . __dict__ ) <EOL> def test_filled_args ( self ) : <EOL> class Test ( steel . Structure ) : <EOL> field1 = steel . Bytes ( size = <NUM_LIT:2> ) <EOL> field2 = steel . Bytes ( size = <NUM_LIT:4> ) <EOL> obj = Test ( field1 = b'<STR_LIT>' , field2 = b'<STR_LIT>' ) <EOL> self . assertEqual ( obj . field1 , b'<STR_LIT>' ) <EOL> self . assertEqual ( obj . field2 , b'<STR_LIT>' ) <EOL> class StructureTupleTests ( unittest . TestCase ) : <EOL> def test_empty_args ( self ) : <EOL> class Test ( steel . StructureTuple ) : <EOL> field1 = steel . Bytes ( size = <NUM_LIT:2> ) <EOL> field2 = steel . Bytes ( size = <NUM_LIT:4> ) <EOL> obj = Test ( ) <EOL> self . assertIsInstance ( obj , tuple ) <EOL> self . assertEqual ( obj . field1 , None ) <EOL> self . assertEqual ( obj . field2 , None ) <EOL> def test_filled_args ( self ) : <EOL> class Test ( steel . Structure ) : <EOL> field1 = steel . Bytes ( size = <NUM_LIT:2> ) <EOL> field2 = steel . Bytes ( size = <NUM_LIT:4> ) <EOL> obj = Test ( field1 = b'<STR_LIT>' , field2 = b'<STR_LIT>' ) <EOL> self . assertEqual ( obj . field1 , b'<STR_LIT>' ) <EOL> self . assertEqual ( obj . field2 , b'<STR_LIT>' ) </s>
