def test_no_env_specified(self): script = """ # conda execute """ msg = 'No environment was found in the .* specification' with tmp_script(script) as fname: with self.assertRaisesRegexp(RuntimeError, msg): execute.execute(fname)
def test_conda_execute_removes_envs_with_no_exe_log(self): script = """ # conda execute # env: # - python >=3 # - numpy # run_with: python """ with tmp_script(script) as fname: fh = open(fname, 'r') spec = conda_execute.execute.extract_spec(fh) env_spec = spec.get('env', []) env_locn = conda_execute.tmpenv.create_env(env_spec) # Remove the execution.log file in this environment to test that # cleanup_tmp_envs removes the environment when it's called exe_log_loc = os.path.join(env_locn, 'conda-meta', 'execution.log') if os.path.exists(exe_log_loc): os.remove(exe_log_loc) conda_execute.tmpenv.cleanup_tmp_envs()
def test_conda_execute_removes_envs_with_no_exe_log(self): script = """ # conda execute # env: # - python >=3 # - numpy # run_with: python """ with tmp_script(script) as fname: fh = open(fname, "r") spec = conda_execute.execute.extract_spec(fh) env_spec = spec.get("env", []) env_locn = conda_execute.tmpenv.create_env(env_spec) # Remove the execution.log file in this environment to test that # cleanup_tmp_envs removes the environment when it's called exe_log_loc = os.path.join(env_locn, "conda-meta", "execution.log") if os.path.exists(exe_log_loc): os.remove(exe_log_loc) conda_execute.tmpenv.cleanup_tmp_envs()
def get_spec(self, script): with tmp_script(script) as fname: with open(fname, 'r') as fh: return execute.extract_spec(fh)