File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from unittest import TestCase
22
3+ from jsonschema .validators import RefResolver
4+
35
46class TestDeprecations (TestCase ):
5- def test_jsonschema_version (self ):
7+ def test_version (self ):
68 """
79 As of v4.0.0, __version__ is deprecated in favor of importlib.metadata.
810 """
@@ -16,7 +18,7 @@ def test_jsonschema_version(self):
1618 ),
1719 )
1820
19- def test_jsonschema_validators_ErrorTree (self ):
21+ def test_validators_ErrorTree (self ):
2022 """
2123 As of v4.0.0, importing ErrorTree from jsonschema.validators is
2224 deprecated in favor of doing so from jsonschema.exceptions.
@@ -30,3 +32,19 @@ def test_jsonschema_validators_ErrorTree(self):
3032 "Importing ErrorTree from jsonschema.validators is deprecated" ,
3133 ),
3234 )
35+
36+ def test_RefResolver_in_scope (self ):
37+ """
38+ As of v4.0.0, RefResolver.in_scope is deprecated.
39+ """
40+
41+ resolver = RefResolver .from_schema ({})
42+ with self .assertWarns (DeprecationWarning ) as w :
43+ with resolver .in_scope ("foo" ):
44+ pass
45+
46+ self .assertTrue (
47+ str (w .warning ).startswith (
48+ "jsonschema.RefResolver.in_scope is deprecated " ,
49+ ),
50+ )
Original file line number Diff line number Diff line change @@ -691,6 +691,11 @@ def in_scope(self, scope):
691691 """
692692 Temporarily enter the given scope for the duration of the context.
693693 """
694+ warnings .warn (
695+ "jsonschema.RefResolver.in_scope is deprecated and will be "
696+ "removed in a future release." ,
697+ DeprecationWarning ,
698+ )
694699 self .push_scope (scope )
695700 try :
696701 yield
You can’t perform that action at this time.
0 commit comments