File: test_misuse.py

package info (click to toggle)
python-genson 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 344 kB
  • sloc: python: 1,385; makefile: 16
file content (27 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from . import base
from genson import Schema, SchemaGenerationError


class TestMisuse(base.SchemaBuilderTestCase):

    def test_schema_with_bad_type_error(self):
        with self.assertRaises(SchemaGenerationError):
            self.add_schema({'type': 'african swallow'})

    def test_to_dict_pending_deprecation_warning(self):
        with self.assertWarns(PendingDeprecationWarning):
            builder = Schema()
        with self.assertWarns(PendingDeprecationWarning):
            builder.add_object('I fart in your general direction!')
            builder.to_dict()

    def test_recurse_deprecation_warning(self):
        with self.assertWarns(DeprecationWarning):
            builder = Schema()
            builder.add_object('Go away or I shall taunt you a second time!')
            builder.to_dict(recurse=True)

    def test_incompatible_schema_warning(self):
        with self.assertWarns(UserWarning):
            self.add_schema({'type': 'string', 'length': 5})
            self.add_schema({'type': 'string', 'length': 7})