Skip to content

Commit c4b6076

Browse files
committed
Add tests to make sure schemas are not being cached
1 parent 1e21491 commit c4b6076

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_integration.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from fastjsonschema import JsonSchemaValueException
3+
from fastjsonschema import JsonSchemaValueException, compile
44

55

66
definition = {
@@ -127,3 +127,18 @@ def test_any_of_with_patterns(asserter):
127127
}, {
128128
'hash': 'AAAXXX',
129129
})
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

0 commit comments

Comments
 (0)