示例#1
0
 def test__validation_fails_when_uuid_is_bad(self):
     example_uuid = str(uuid.uuid4()) + "can't-be-a-uuid"
     validator = config.UUIDString(accept_python=False)
     expected_exception = ExpectedException(
         formencode.validators.Invalid,
         "^%s$" % re.escape("%r Failed to parse UUID" % example_uuid))
     with expected_exception:
         validator.from_python(example_uuid)
     with expected_exception:
         validator.to_python(example_uuid)
示例#2
0
 def test__validation_succeeds_when_uuid_is_good(self):
     example_uuid = str(uuid.uuid4())
     validator = config.UUIDString(accept_python=False)
     self.assertEqual(example_uuid, validator.from_python(example_uuid))
     self.assertEqual(example_uuid, validator.to_python(example_uuid))