<s> from ctypes import * <EOL> from support import BaseCTypesTestChecker <EOL> class TestUnion ( BaseCTypesTestChecker ) : <EOL> def test_getattr ( self ) : <EOL> class Stuff ( Union ) : <EOL> _fields_ = [ ( '<STR_LIT:x>' , c_char ) , ( '<STR_LIT:y>' , c_int ) ] <EOL> stuff = Stuff ( ) <EOL> stuff . y = ord ( '<STR_LIT:x>' ) <EOL> assert stuff . x == '<STR_LIT:x>' <EOL> def test_union_of_structures ( self ) : <EOL> class Stuff ( Structure ) : <EOL> _fields_ = [ ( '<STR_LIT:x>' , c_int ) ] <EOL> class Stuff2 ( Structure ) : <EOL> _fields_ = [ ( '<STR_LIT:x>' , c_int ) ] <EOL> class UnionofStuff ( Union ) : <EOL> _fields_ = [ ( '<STR_LIT>' , Stuff ) , <EOL> ( '<STR_LIT>' , Stuff2 ) ] <EOL> u = UnionofStuff ( ) <EOL> u . one . x = <NUM_LIT:3> <EOL> assert u . two . x == <NUM_LIT:3> </s>
