Python jsonschema.FormatError() Examples
The following are 11
code examples of jsonschema.FormatError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
jsonschema
, or try the search function
.
Example #1
Source File: test_format.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #2
Source File: test_format.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #3
Source File: test_format.py From core with MIT License | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #4
Source File: test_format.py From deepWordBug with Apache License 2.0 | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #5
Source File: test_format.py From accelerated-data-lake with Apache License 2.0 | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #6
Source File: test_format.py From Requester with MIT License | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #7
Source File: test_format.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #8
Source File: test_format.py From pyblish-qml with GNU Lesser General Public License v3.0 | 6 votes |
def test_it_catches_registered_errors(self): checker = FormatChecker() cause = self.fn.side_effect = ValueError() checker.checks("foo", raises=ValueError)(self.fn) with self.assertRaises(FormatError) as cm: checker.check("bar", "foo") self.assertIs(cm.exception.cause, cause) self.assertIs(cm.exception.__cause__, cause) # Unregistered errors should not be caught self.fn.side_effect = AttributeError with self.assertRaises(AttributeError): checker.check("bar", "foo")
Example #9
Source File: util.py From counterblock with MIT License | 5 votes |
def parse_iso8601_interval(value): try: return aniso8601.parse_interval(value) except Exception: try: return aniso8601.parse_repeating_interval(value) except Exception: raise FormatError('{} is not an iso8601 interval'.format(value))
Example #10
Source File: request.py From trains-agent with Apache License 2.0 | 5 votes |
def validate(self): if not self._validate_requests or self._allow_raw_requests: return for i, req in enumerate(self.requests): try: req.validate() except (jsonschema.SchemaError, jsonschema.ValidationError, jsonschema.FormatError, jsonschema.RefResolutionError) as e: raise Exception('Validation error in batch item #%d: %s' % (i, str(e)))
Example #11
Source File: request.py From trains with Apache License 2.0 | 5 votes |
def validate(self): if not self._validate_requests or self._allow_raw_requests: return for i, req in enumerate(self.requests): try: req.validate() except (jsonschema.SchemaError, jsonschema.ValidationError, jsonschema.FormatError, jsonschema.RefResolutionError) as e: raise Exception('Validation error in batch item #%d: %s' % (i, str(e)))