File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ def test_compile_to_code_custom_format():
99
99
assert exc .value .message == "data must be my-format"
100
100
101
101
102
- def test_compile_to_code_custom_format_with_refs ():
102
+ def test_compile_to_code_custom_format_with_refs (tmp_path , monkeypatch ):
103
103
schema = {
104
104
'type' : 'object' ,
105
105
'properties' : {
@@ -115,9 +115,12 @@ def test_compile_to_code_custom_format_with_refs():
115
115
}
116
116
formats = {'my-format' : str .isidentifier }
117
117
code = compile_to_code (schema , formats = formats )
118
- with open ('temp/schema_4.py' , 'w' ) as f :
119
- f .write (code )
120
- from temp .schema_4 import validate
118
+
119
+ (tmp_path / "schema_4.py" ).write_text (code )
120
+ with monkeypatch .context () as m :
121
+ m .syspath_prepend (tmp_path )
122
+ from schema_4 import validate
123
+
121
124
assert validate ({"a" : ["identifier" ]}, formats ) is not None
122
125
with pytest .raises (JsonSchemaValueException ) as exc :
123
126
validate ({"a" : ["identifier" , "not-valid" ]}, formats )
You can’t perform that action at this time.
0 commit comments