Skip to content

Commit b14bd17

Browse files
committed
Keep with-blocks for patch CMs, trigger lazy properties inside context, and move assertIn outside
1 parent 5c9f85a commit b14bd17

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎Lib/test/test_filecmp.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,10 @@ def fake_stat(path, *args, **kwargs):
444444
raise OSError
445445
return original_stat(path, *args, **kwargs)
446446

447-
self.enterContext(patch("os.stat", side_effect=fake_stat))
448-
dc = filecmp.dircmp(self.dir, self.dir_same)
447+
with patch("os.stat", side_effect=fake_stat):
448+
dc = filecmp.dircmp(self.dir, self.dir_same)
449+
dc.common_funny
450+
449451
self.assertIn(trigger_file, dc.common_funny)
450452

451453
# Test common_funny layout with regular files, directories, and sockets.
@@ -482,8 +484,10 @@ def fake_stat_types(path, *args, **kwargs):
482484

483485
return st
484486

485-
self.enterContext(patch("os.stat", side_effect=fake_stat_types))
486-
dc = filecmp.dircmp(self.dir, self.dir_same)
487+
with patch("os.stat", side_effect=fake_stat_types):
488+
dc = filecmp.dircmp(self.dir, self.dir_same)
489+
dc.common_funny
490+
487491
self.assertIn(file_diff_type, dc.common_funny)
488492
self.assertIn(file_funny_type, dc.common_funny)
489493

0 commit comments

Comments
 (0)