Codebase list voluptuous / 77eeebb5-7f40-48f5-95a6-b7a3be703de0/upstream
Import upstream version 0.12.1+git20210220.1.1720439, md5 1ed390485c486d1c9b11850f0174f933 Debian Janitor 3 years ago
2 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
515515 )
516516 assert_equal(repr(coerce_), "Coerce(int, msg='moo')")
517517 assert_equal(repr(all_), "All('10', Coerce(int, msg=None), msg='all msg')")
518 assert_equal(repr(maybe_int), "Any(%s, None, msg=None)" % str(int))
518 assert_equal(repr(maybe_int), "Any(None, %s, msg=None)" % str(int))
519519
520520
521521 def test_list_validation_messages():
746746 assert s([])
747747
748748
749 def test_maybe_returns_subvalidator_error():
749 def test_maybe_returns_default_error():
750750 schema = Schema(Maybe(Range(1, 2)))
751751
752752 # The following should be valid
758758 # Should trigger a MultipleInvalid exception
759759 schema(3)
760760 except MultipleInvalid as e:
761 assert_equal(str(e), "value must be at most 2")
761 assert_equal(str(e), "not a valid value")
762762 else:
763763 assert False, "Did not raise correct Invalid"
764764
351351 >>> validate = Schema(Match(r'^0x[A-F0-9]+$'))
352352 >>> validate('0x123EF4')
353353 '0x123EF4'
354 >>> with raises(MultipleInvalid, "does not match regular expression"):
354 >>> with raises(MultipleInvalid, 'does not match regular expression ^0x[A-F0-9]+$'):
355355 ... validate('123EF4')
356356
357357 >>> with raises(MultipleInvalid, 'expected string or buffer'):
376376 except TypeError:
377377 raise MatchInvalid("expected string or buffer")
378378 if not match:
379 raise MatchInvalid(self.msg or 'does not match regular expression')
379 raise MatchInvalid(self.msg or 'does not match regular expression {}'.format(self.pattern.pattern))
380380 return v
381381
382382 def __repr__(self):
554554 ... s("string")
555555
556556 """
557 return Any(validator, None, msg=msg)
557 return Any(None, validator, msg=msg)
558558
559559
560560 class Range(object):