Skip to content

Commit

Permalink
Add tests to make sure schemas are not being cached
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Dec 23, 2021
1 parent 1e21491 commit c4b6076
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from fastjsonschema import JsonSchemaValueException
from fastjsonschema import JsonSchemaValueException, compile


definition = {
Expand Down Expand Up @@ -127,3 +127,18 @@ def test_any_of_with_patterns(asserter):
}, {
'hash': 'AAAXXX',
})


def test_swap_handlers():
# Make sure that by swapping resolvers, the schemas do not get cached
repo1 = {
"sch://schema": {"type": "array"}
}
validator1 = compile({"$ref": "sch://schema"}, handlers={"sch": repo1.__getitem__})
assert validator1([1, 2, 3]) is not None

repo2 = {
"sch://schema": {"type": "string"}
}
validator2 = compile({"$ref": "sch://schema"}, handlers={"sch": repo2.__getitem__})
assert validator2("hello world") is not None

0 comments on commit c4b6076

Please sign in to comment.