PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/python/python_nondynamic_runme.py

#
Python | 46 lines | 36 code | 10 blank | 0 comment | 6 complexity | 4572d74653f0f81770afe07fa2e4c42a MD5 | raw file
 1import python_nondynamic
 2
 3aa = python_nondynamic.A()
 4
 5aa.a = 1
 6aa.b = 2
 7try:
 8  aa.c = 2
 9  err = 0
10except:
11  err = 1
12
13if not err:  
14  raise RuntimeError, "A is not static"  
15
16class B(python_nondynamic.A):
17  c = 4
18  def __init__(self):
19    python_nondynamic.A.__init__(self)
20    pass
21  pass
22
23bb = B()
24
25try:
26  bb.c = 3
27  err = 0
28except:
29  err = 1
30
31if not err:
32  print "bb.c = %d" % bb.c
33  print "B.c = %d" % B.c
34  raise RuntimeError, "B.c class variable messes up nondynamic-ness of B"
35
36try:
37  bb.d = 2
38  err = 0
39except:
40  err = 1
41
42if not err:  
43  raise RuntimeError, "B is not static"  
44      
45cc = python_nondynamic.C()
46cc.d = 3