<s> import unittest <EOL> from ctypes import * <EOL> class AnonTest ( unittest . TestCase ) : <EOL> def test_anon ( self ) : <EOL> class ANON ( Union ) : <EOL> _fields_ = [ ( "<STR_LIT:a>" , c_int ) , <EOL> ( "<STR_LIT:b>" , c_int ) ] <EOL> class Y ( Structure ) : <EOL> _fields_ = [ ( "<STR_LIT:x>" , c_int ) , <EOL> ( "<STR_LIT:_>" , ANON ) , <EOL> ( "<STR_LIT:y>" , c_int ) ] <EOL> _anonymous_ = [ "<STR_LIT:_>" ] <EOL> self . assertEqual ( Y . a . offset , sizeof ( c_int ) ) <EOL> self . assertEqual ( Y . b . offset , sizeof ( c_int ) ) <EOL> self . assertEqual ( ANON . a . offset , <NUM_LIT:0> ) <EOL> self . assertEqual ( ANON . b . offset , <NUM_LIT:0> ) <EOL> def test_anon_nonseq ( self ) : <EOL> self . assertRaises ( TypeError , <EOL> lambda : type ( Structure ) ( "<STR_LIT:Name>" , <EOL> ( Structure , ) , <EOL> { "<STR_LIT>" : [ ] , "<STR_LIT>" : <NUM_LIT> } ) ) <EOL> def test_anon_nonmember ( self ) : <EOL> self . assertRaises ( AttributeError , <EOL> lambda : type ( Structure ) ( "<STR_LIT:Name>" , <EOL> ( Structure , ) , <EOL> { "<STR_LIT>" : [ ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:x>" ] } ) ) <EOL> def test_nested ( self ) : <EOL> class ANON_S ( Structure ) : <EOL> _fields_ = [ ( "<STR_LIT:a>" , c_int ) ] <EOL> class ANON_U ( Union ) : <EOL> _fields_ = [ ( "<STR_LIT:_>" , ANON_S ) , <EOL> ( "<STR_LIT:b>" , c_int ) ] <EOL> _anonymous_ = [ "<STR_LIT:_>" ] <EOL> class Y ( Structure ) : <EOL> _fields_ = [ ( "<STR_LIT:x>" , c_int ) , <EOL> ( "<STR_LIT:_>" , ANON_U ) , <EOL> ( "<STR_LIT:y>" , c_int ) ] <EOL> _anonymous_ = [ "<STR_LIT:_>" ] <EOL> self . assertEqual ( Y . x . offset , <NUM_LIT:0> ) <EOL> self . assertEqual ( Y . a . offset , sizeof ( c_int ) ) <EOL> self . assertEqual ( Y . b . offset , sizeof ( c_int ) ) <EOL> self . assertEqual ( Y . _ . offset , sizeof ( c_int ) ) <EOL> self . assertEqual ( Y . y . offset , sizeof ( c_int ) * <NUM_LIT:2> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
