comparison transformations/testmod.py @ 296:089f236759d9

Fix testmod so that modules with no parameters are accepted.
author Arnaud Bergeron <abergeron@gmail.com>
date Wed, 10 Feb 2010 10:58:44 -0500
parents 368f1907ad5a
children 6f606b359df3
comparison
equal deleted inserted replaced
70:be24db3a4d6e 296:089f236759d9
54 names = mod.get_settings_names() 54 names = mod.get_settings_names()
55 55
56 if type(names) is not list: 56 if type(names) is not list:
57 error("Must return a list") 57 error("Must return a list")
58 58
59 if len(names) == 0:
60 error("Must return at least one element")
61
62 if not all(type(e) is str for e in names): 59 if not all(type(e) is str for e in names):
63 warn("The elements of the list should be strings") 60 warn("The elements of the list should be strings")
64 61
65 ########################### 62 ###########################
66 # regenerate_parameters() # 63 # regenerate_parameters() #
75 72
76 if len(params) != len(names): 73 if len(params) != len(names):
77 error("the returned parameter list must have the same length as the number of parameters") 74 error("the returned parameter list must have the same length as the number of parameters")
78 75
79 params2 = mod.regenerate_parameters(0.2) 76 params2 = mod.regenerate_parameters(0.2)
80 if params == params2: 77 if len(names) != 0 && params == params2:
81 error("the complexity parameter determines the distribution of the parameters, not their value") 78 error("the complexity parameter determines the distribution of the parameters, not their value")
82 79
83 mod.regenerate_parameters(0.0) 80 mod.regenerate_parameters(0.0)
84 mod.regenerate_parameters(1.0) 81 mod.regenerate_parameters(1.0)
85 82