@@ -18,14 +18,19 @@ def iter_errors(self, instance):
18
18
19
19
20
20
class TestParser (unittest .TestCase ):
21
-
22
21
FakeValidator = fake_validator ()
23
22
24
23
def setUp (self ):
25
- self .open = mock .mock_open (read_data = '{}' )
26
- patch = mock .patch .object (cli , "open" , self .open , create = True )
27
- patch .start ()
28
- self .addCleanup (patch .stop )
24
+ mock_open = mock .mock_open ()
25
+ patch_open = mock .patch .object (cli , "open" , mock_open , create = True )
26
+ patch_open .start ()
27
+ self .addCleanup (patch_open .stop )
28
+
29
+ mock_json_load = mock .Mock ()
30
+ mock_json_load .return_value = {}
31
+ patch_json_load = mock .patch ("json.load" )
32
+ patch_json_load .start ()
33
+ self .addCleanup (patch_json_load .stop )
29
34
30
35
def test_find_validator_by_fully_qualified_object_name (self ):
31
36
arguments = cli .parse_args (
@@ -54,10 +59,10 @@ def test_successful_validation(self):
54
59
stdout , stderr = StringIO (), StringIO ()
55
60
exit_code = cli .run (
56
61
{
57
- "validator" : fake_validator (),
58
- "schema" : {},
59
- "instances" : [1 ],
60
- "error_format" : "{error.message}" ,
62
+ "validator" : fake_validator (),
63
+ "schema" : {},
64
+ "instances" : [1 ],
65
+ "error_format" : "{error.message}" ,
61
66
},
62
67
stdout = stdout ,
63
68
stderr = stderr ,
@@ -71,10 +76,10 @@ def test_unsuccessful_validation(self):
71
76
stdout , stderr = StringIO (), StringIO ()
72
77
exit_code = cli .run (
73
78
{
74
- "validator" : fake_validator ([error ]),
75
- "schema" : {},
76
- "instances" : [1 ],
77
- "error_format" : "{error.instance} - {error.message}" ,
79
+ "validator" : fake_validator ([error ]),
80
+ "schema" : {},
81
+ "instances" : [1 ],
82
+ "error_format" : "{error.instance} - {error.message}" ,
78
83
},
79
84
stdout = stdout ,
80
85
stderr = stderr ,
@@ -92,10 +97,10 @@ def test_unsuccessful_validation_multiple_instances(self):
92
97
stdout , stderr = StringIO (), StringIO ()
93
98
exit_code = cli .run (
94
99
{
95
- "validator" : fake_validator (first_errors , second_errors ),
96
- "schema" : {},
97
- "instances" : [1 , 2 ],
98
- "error_format" : "{error.instance} - {error.message}\t " ,
100
+ "validator" : fake_validator (first_errors , second_errors ),
101
+ "schema" : {},
102
+ "instances" : [1 , 2 ],
103
+ "error_format" : "{error.instance} - {error.message}\t " ,
99
104
},
100
105
stdout = stdout ,
101
106
stderr = stderr ,
0 commit comments