Changeset 474
- Timestamp:
- 11/02/10 17:49:15 (19 months ago)
- Files:
-
- 1 modified
-
trunk/test/test_validators.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/test_validators.py
r465 r474 100 100 assert r == False 101 101 102 def test_complex_eval(self): 103 104 p_str = """ 105 list: [1,2,3,4] 106 flist: [1.0,2.0,3.0,4.0] 107 """ 108 109 s_str = """ 110 list: !!python/object:NeuroTools.parameters.validators.Eval { expr: 'isinstance(x,list) and all([isinstance(elem,int) for elem in x])', var: 'x'} 111 flist: !!python/object:NeuroTools.parameters.validators.Eval { expr: 'isinstance(x,list) and all([isinstance(elem,float) for elem in x])', var: 'x'} 112 """ 113 114 115 s1 = ParameterSchema(yaml.load(s_str)) 116 p1 = ParameterSet(yaml.load(p_str)) 117 118 v = CongruencyValidator() 119 # test Eval which checks for isinstance(x,list) 120 #s1.mylist = NeuroTools.parameters.validators.Eval('isinstance(x,list) and all([isinstance(elem,int) for elem in x])',var='x') 121 assert v.validate(p1,s1)==True 122 123 102 124 103 125 def test_simple_validate(self): … … 135 157 all: /somewhere1/path1.xml 136 158 specific: /somewhere2/path2.xml 159 numbers: 160 float: 1.0 137 161 """ 138 162 139 163 schema_str = """ 140 164 # user info 141 username: Subclass(type=str) 142 email: Subclass(type=str) 143 144 # recipes 145 recipes: 146 all: Subclass(type=str) 147 specific: Subclass(type=str) 165 username: '' 166 email: '' 167 168 # recipes 169 recipes: 170 all: '' 171 specific: '' 172 numbers: 173 float: !!python/object:NeuroTools.parameters.validators.Subclass { type: !!python/name:float } 148 174 """ 149 175 … … 179 205 all: /somewhere1/path1.xml 180 206 specific: /somewhere2/path2.xml 207 numbers: 208 float: 1.0 181 209 """ 182 210 183 211 schema_str = """ 184 212 # user info 185 username: Subclass(type=str) 186 email: Subclass(type=str) 187 188 # recipes 189 recipes: 190 all: Subclass(type=str) 191 specific: Subclass(type=str) 213 username: '' 214 email: '' 215 216 # recipes 217 recipes: 218 all: '' 219 specific: '' 220 numbers: 221 float: !!python/object:NeuroTools.parameters.validators.Subclass { type: !!python/name:float } 192 222 """ 193 223
