def test_must_close_opened_logfile(self): context = InvokeContext(template_file="template") handle_mock = Mock() context._log_file_handle = handle_mock context.__exit__() handle_mock.close.assert_called_with() self.assertIsNone(context._log_file_handle)
def test_must_ignore_if_handle_is_absent(self): context = InvokeContext(template_file="template") context._log_file_handle = None context.__exit__() self.assertIsNone(context._log_file_handle)