def setUp(self): # set up a temp file to use as env file so we don't mess up real defaults self.test_env_file = NamedTemporaryFile(delete=False).name mock_env_file_patcher = mock.patch('stor.cli.ENV_FILE', self.test_env_file) self.mock_env_file = mock_env_file_patcher.start() self.addCleanup(mock_env_file_patcher.stop) with mock.patch('os.path.exists', return_value=False, autospec=True): cli._clear_env() super(TestCd, self).setUp()
def tearDown(self): cli._clear_env() os.remove(self.test_env_file) super(TestCd, self).tearDown()