def __del__(self): if hasattr(self, 'ftp') and self.ftp: # pragma: no cover self.ftp.close() if hasattr(self, 'webdriver') and self.webdriver: unload_driver(self.webdriver) if hasattr(self, 'vdisplay') and self.vdisplay: unload_vdisplay(self.vdisplay)
def __exit__(self, *args, **kwargs): # pragma: no cover if hasattr(self, 'ftp'): self.ftp.close() if hasattr(self, 'webdriver'): unload_driver(self.webdriver) if hasattr(self, 'vdisplay'): unload_vdisplay(self.vdisplay) super(Cabu, self).__exit__(*args, **kwargs)
def test_unload_driver_fail(self, mock_driver): driver = load_driver(self.config) mock_driver.assert_called_once_with(self.config) driver.close = Mock() driver.close.side_effect = Exception("Boom !") unload_driver(driver)
def test_load_driver(self, mock_driver): driver = load_driver(self.config) mock_driver.assert_called_once_with(self.config) unload_driver(driver)