Add test for tmp_env_file removal

This commit is contained in:
Simon Boehm 2020-12-21 17:44:44 +01:00
parent a2ca862130
commit 9c9e8c1ac4
No known key found for this signature in database
GPG key ID: 59DF9146ABE67092
2 changed files with 49 additions and 2 deletions

View file

@ -67,6 +67,7 @@ def install_environment(
with open(env_yaml_path) as env_file:
env_yaml = yaml_load(env_file)
env_yaml['dependencies'] += additional_dependencies
tmp_env_file = None
try:
with NamedTemporaryFile(
suffix='.yml',
@ -80,7 +81,7 @@ def install_environment(
tmp_env_file.name, cwd=prefix.prefix_dir,
)
finally:
if os.path.exists(tmp_env_file.name):
if tmp_env_file and os.path.exists(tmp_env_file.name):
os.remove(tmp_env_file.name)