def test_applied_context_manager(mocker, patches, cwd, is_exception): patch_mock = mocker.patch("octane.util.patch.patch_apply") class TestException(Exception): pass if is_exception: with pytest.raises(TestException): with patch.applied_patch(cwd, *patches): raise TestException else: with patch.applied_patch(cwd, *patches): pass assert [ mock.call(cwd, patches), mock.call(cwd, patches[::-1], revert=True) ] == patch_mock.call_args_list
def restore(self): with patch.applied_patch(*self.patches): super(NailgunArchivator, self).restore()