Пример #1
0
    def test_multi_constant(self):  # type: () -> None
        """
        Tests constants with multiple options
        """
        schema = Constant(42, 36, 81, 9231)
        self.assertEqual(
            schema.errors(9231),
            [],
        )
        self.assertEqual(
            schema.errors(81),
            [],
        )
        self.assertEqual(
            schema.errors(360000),
            [
                Error('Value is not one of: 36, 42, 81, 9231',
                      code=ERROR_CODE_UNKNOWN)
            ],
        )

        with pytest.raises(TypeError):
            Constant(42, 36, 81, 9231, description='foo', unsupported='bar')

        with pytest.raises(ValueError):
            Constant()

        with pytest.raises(TypeError):
            Constant(42, 36, 81, 9231, description=b'not unicode')
Пример #2
0
 def test_multi_constant(self):
     """
     Tests constants with multiple options
     """
     schema = Constant(42, 36, 81, 9231)
     self.assertEqual(
         schema.errors(9231),
         [],
     )
     self.assertEqual(
         schema.errors(81),
         [],
     )
     self.assertEqual(
         schema.errors(360000),
         [
             Error('Value is not one of: 36, 42, 81, 9231',
                   code=ERROR_CODE_UNKNOWN)
         ],
     )