1. Ludia
  2. Untitled project
  3. onctuous

Commits

Jean-Tiare Le Bigot  committed a4fa0d1

main validate fully tested

  • Participants
  • Parent commits bb0cdd6
  • Branches default

Comments (0)

Files changed (1)

File tests/unit/test_schema.py

View file
  • Ignore whitespace
 
 import unittest, mock
 
+MSG1 = "msg 1"
+MSG2 = "msg 2"
+
 class TestSchema(unittest.TestCase):
     def test_schema_init(self):
         from voluptuous import Schema
         m_val_list.assert_called_once_with([], ['a', 'b'], ['a', 'b'])
         self.assertFalse(m_val_scalar.called)
         self.assertFalse(m_val_dict.called)
+
+
+    @mock.patch('voluptuous.Schema.validate_dict')
+    @mock.patch('voluptuous.Schema.validate_list')
+    @mock.patch('voluptuous.Schema.validate_scalar')
+    def test_schema_validate_scalar_error(self, m_val_scalar, m_val_list, m_val_dict):
+        from voluptuous import Schema, InvalidList, Invalid
+
+        m_val_scalar.side_effect = Invalid(MSG1)
+        self.assertRaisesRegexp(InvalidList, MSG1, Schema(None).validate, [], int, 123)
+
+        m_val_scalar.side_effect = InvalidList([Invalid(MSG1)])
+        self.assertRaisesRegexp(InvalidList, MSG1, Schema(None).validate, [], int, 123)