File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -288,19 +288,17 @@ def __eq__(self, other):
288
288
class KUnitMainTest (unittest .TestCase ):
289
289
def setUp (self ):
290
290
path = get_absolute_path ('test_data/test_is_test_passed-all_passed.log' )
291
- file = open (path )
292
- all_passed_log = file .readlines ()
293
- self .print_patch = mock .patch ('builtins.print' )
294
- self .print_mock = self .print_patch .start ()
291
+ with open (path ) as file :
292
+ all_passed_log = file .readlines ()
293
+
294
+ self .print_mock = mock .patch ('builtins.print' ).start ()
295
+ self .addCleanup (mock .patch .stopall )
296
+
295
297
self .linux_source_mock = mock .Mock ()
296
298
self .linux_source_mock .build_reconfig = mock .Mock (return_value = True )
297
299
self .linux_source_mock .build_um_kernel = mock .Mock (return_value = True )
298
300
self .linux_source_mock .run_kernel = mock .Mock (return_value = all_passed_log )
299
301
300
- def tearDown (self ):
301
- self .print_patch .stop ()
302
- pass
303
-
304
302
def test_config_passes_args_pass (self ):
305
303
kunit .main (['config' , '--build_dir=.kunit' ], self .linux_source_mock )
306
304
assert self .linux_source_mock .build_reconfig .call_count == 1
You can’t perform that action at this time.
0 commit comments