|
17 | 17 | import mock
|
18 | 18 |
|
19 | 19 | from jsonschema import (
|
20 |
| - PY3, SchemaError, UnknownType, ValidationError, ErrorTree, |
| 20 | + PY3, abc, SchemaError, UnknownType, ValidationError, ErrorTree, |
21 | 21 | Draft3Validator, FormatChecker, RefResolver, validate
|
22 | 22 | )
|
23 | 23 |
|
@@ -71,11 +71,18 @@ def add_test_methods(test_class):
|
71 | 71 | return add_test_methods
|
72 | 72 |
|
73 | 73 |
|
74 |
| -class BytesMixin(object): |
| 74 | +class TypesMixin(object): |
75 | 75 | @unittest.skipIf(PY3, "In Python 3 json.load always produces unicode")
|
76 | 76 | def test_string_a_bytestring_is_a_string(self):
|
77 | 77 | self.validator_class({"type" : "string"}).validate(b"foo")
|
78 | 78 |
|
| 79 | + def test_mappings_are_objects(self): |
| 80 | + class Mapping(abc.Mapping): |
| 81 | + def __getitem__(self): return 12 |
| 82 | + def __iter__(self): return iter([]) |
| 83 | + def __len__(self): return 12 |
| 84 | + self.validator_class({"type" : "object"}).validate(Mapping()) |
| 85 | + |
79 | 86 |
|
80 | 87 | class DecimalMixin(object):
|
81 | 88 | def test_it_can_validate_with_decimals(self):
|
@@ -123,7 +130,7 @@ def test_it_validates_formats_if_a_checker_is_provided(self):
|
123 | 130 |
|
124 | 131 | @load_json_cases("json/tests/draft3/*.json")
|
125 | 132 | @load_json_cases("json/tests/draft3/optional/bignum.json")
|
126 |
| -class TestDraft3(unittest.TestCase, BytesMixin, DecimalMixin, FormatMixin): |
| 133 | +class TestDraft3(unittest.TestCase, TypesMixin, DecimalMixin, FormatMixin): |
127 | 134 |
|
128 | 135 | validator_class = Draft3Validator
|
129 | 136 |
|
|
0 commit comments