- Timestamp:
- 08/25/10 17:28:08 (21 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/parameter_set_schema_validation/test/test_validators.py
r454 r456 48 48 'true': NeuroTools.parameters.validators.Subclass(type=bool), 49 49 'yourlist': NeuroTools.parameters.validators.Subclass(type=list), 50 'ps2': {'ps.a': NeuroTools.parameters.validators.Subclass(type=int), 51 'c': NeuroTools.parameters.validators.Subclass(type=int), 52 'ps.b': NeuroTools.parameters.validators.Subclass(type=int)}, 'null': NeuroTools.parameters.validators.Subclass(type=NoneType), 'mydict': {'c': NeuroTools.parameters.validators.Subclass(type=int), 'd': NeuroTools.parameters.validators.Subclass(type=int)}, 'hello': NeuroTools.parameters.validators.Subclass(type=str)} 50 'ps2': {'ps': {'a':NeuroTools.parameters.validators.Subclass(type=int), 51 'b':NeuroTools.parameters.validators.Subclass(type=int)}, 52 'c': NeuroTools.parameters.validators.Subclass(type=int)}, 53 'null': NeuroTools.parameters.validators.Subclass(type=type(None)), 54 'mydict': {'c': NeuroTools.parameters.validators.Subclass(type=int), 55 'd': NeuroTools.parameters.validators.Subclass(type=int)}, 56 'hello': NeuroTools.parameters.validators.Subclass(type=str)}) 53 57 54 58 … … 63 67 64 68 69 def test_validate_generated_schema(self): 70 s1 = ParameterSchema(ps3) 71 72 v = CongruencyValidator() 73 assert v.validate(ps3,s1)==True 74 65 75 def test_simple_validate(self): 76 v = CongruencyValidator() 77 assert v.validate(ps3,schema3)==True 78 79 def test_validation_failure_info(self): 80 """ Test the error output for an failed validation against a schema""" 81 66 82 s1 = ParameterSchema(ps3) 67 print s168 #print ps3.flatten()69 83 84 s1.ps2.ps.a = Subclass(type=float) 85 v = CongruencyValidator() 86 r = False 87 try: 88 r = v.validate(ps3,s1) 89 except Exception as e: 90 assert isinstance(e,ValidationError) 91 assert e.path=='ps2.ps.a' 92 assert e.parameter==ps3.ps2.ps.a 93 assert e.schema_base==s1.ps2.ps.a 94 assert r==False 70 95 71 96 def test_congruent_dicts(self):
