def setUp(self): self.meta_schema = {u"properties": {u"smelly": {}}} self.smelly = mock.MagicMock() self.validators = {u"smelly": self.smelly} self.type_checker = TypeChecker() self.Validator = validators.create(meta_schema=self.meta_schema, validators=self.validators, type_checker=self.type_checker) self.validator_value = 12 self.schema = {u"smelly": self.validator_value} self.validator = self.Validator(self.schema)
def setUp(self): self.meta_schema = {u"properties": {u"smelly": {}}} self.smelly = mock.MagicMock() self.validators = {u"smelly": self.smelly} self.types = {u"dict": dict} self.Validator = create( meta_schema=self.meta_schema, validators=self.validators, default_types=self.types, ) self.validator_value = 12 self.schema = {u"smelly": self.validator_value} self.validator = self.Validator(self.schema)
def test_str_works_with_instances_having_overriden_eq_operator(self): """ Check for https://github.com/Julian/jsonschema/issues/164 which rendered exceptions unusable when a `ValidationError` involved instances with an `__eq__` method that returned truthy values. """ instance = mock.MagicMock() error = exceptions.ValidationError( "a message", validator="foo", instance=instance, validator_value="some", schema="schema", ) str(error) self.assertFalse(instance.__eq__.called)
def test_it_knows_how_many_total_errors_it_contains(self): errors = [mock.MagicMock() for _ in range(8)] tree = exceptions.ErrorTree(errors) self.assertEqual(tree.total_errors, 8)
def setUp(self): self.meta_schema = {u"properties": {u"smelly": {}}} self.smelly = mock.MagicMock() self.validators = {u"smelly": self.smelly}