File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
- from fastjsonschema import JsonSchemaValueException
3
+ from fastjsonschema import JsonSchemaValueException , compile
4
4
5
5
6
6
definition = {
@@ -127,3 +127,18 @@ def test_any_of_with_patterns(asserter):
127
127
}, {
128
128
'hash' : 'AAAXXX' ,
129
129
})
130
+
131
+
132
+ def test_swap_handlers ():
133
+ # Make sure that by swapping resolvers, the schemas do not get cached
134
+ repo1 = {
135
+ "sch://schema" : {"type" : "array" }
136
+ }
137
+ validator1 = compile ({"$ref" : "sch://schema" }, handlers = {"sch" : repo1 .__getitem__ })
138
+ assert validator1 ([1 , 2 , 3 ]) is not None
139
+
140
+ repo2 = {
141
+ "sch://schema" : {"type" : "string" }
142
+ }
143
+ validator2 = compile ({"$ref" : "sch://schema" }, handlers = {"sch" : repo2 .__getitem__ })
144
+ assert validator2 ("hello world" ) is not None
You can’t perform that action at this time.
0 commit comments