1import struct_value 2 3b = struct_value.Bar() 4 5b.a.x = 3 6if b.a.x != 3: 7 raise RuntimeError 8 9b.b.x = 3 10if b.b.x != 3: 11 raise RuntimeError 12 13 14# Test dynamically added attributes - Github pull request #320 15b.added = 123 16 17if b.added != 123: 18 raise RuntimeError("Wrong attribute value") 19 20if not b.__dict__.has_key("added"): 21 raise RuntimeError("Missing added attribute in __dict__") 22 23 24class PyBar(struct_value.Bar): 25 26 def __init__(self): 27 self.extra = "hi" 28 struct_value.Bar.__init__(self) 29 30pybar = PyBar() 31if not pybar.__dict__.has_key("extra"): 32 raise RuntimeError("Missing extra attribute in __dict__") 33if pybar.extra != "hi": 34 raise RuntimeError("Incorrect attribute value for extra") 35