File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
from unittest import TestCase
2
2
3
+ from jsonschema .validators import RefResolver
4
+
3
5
4
6
class TestDeprecations (TestCase ):
5
- def test_jsonschema_version (self ):
7
+ def test_version (self ):
6
8
"""
7
9
As of v4.0.0, __version__ is deprecated in favor of importlib.metadata.
8
10
"""
@@ -16,7 +18,7 @@ def test_jsonschema_version(self):
16
18
),
17
19
)
18
20
19
- def test_jsonschema_validators_ErrorTree (self ):
21
+ def test_validators_ErrorTree (self ):
20
22
"""
21
23
As of v4.0.0, importing ErrorTree from jsonschema.validators is
22
24
deprecated in favor of doing so from jsonschema.exceptions.
@@ -30,3 +32,19 @@ def test_jsonschema_validators_ErrorTree(self):
30
32
"Importing ErrorTree from jsonschema.validators is deprecated" ,
31
33
),
32
34
)
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):
691
691
"""
692
692
Temporarily enter the given scope for the duration of the context.
693
693
"""
694
+ warnings .warn (
695
+ "jsonschema.RefResolver.in_scope is deprecated and will be "
696
+ "removed in a future release." ,
697
+ DeprecationWarning ,
698
+ )
694
699
self .push_scope (scope )
695
700
try :
696
701
yield
You can’t perform that action at this time.
0 commit comments