Skip to content

Commit

Permalink
Add unit test and complete variable name change
Browse files Browse the repository at this point in the history
  • Loading branch information
joasode committed Nov 26, 2024
1 parent 2266268 commit 9865469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cotainr/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def add_to_env(self, *, shell_script):

env_file = self.sandbox_dir / ".singularity.d/env/92-cotainr-env.sh"
if not env_file.exists():
self._create_file(env_file=env_file)
self._create_file(f=env_file)

with env_file.open(mode="a") as f:
f.write(shell_script + "\n")
Expand Down
10 changes: 9 additions & 1 deletion cotainr/tests/container/test_singularity_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ def test_tmp_dir_setup_and_teardown(self, patch_disable_stream_subprocess):
assert not sandbox_dir.exists()


class TestCreateFile:
def test_broken_subprocess(self, patch_disable_stream_subprocess):
with SingularitySandbox(base_image="my_base_image_6021") as sandbox:
any_file = sandbox.sandbox_dir / "anyfile.txt"
with pytest.raises(FileNotFoundError):
sandbox._create_file(f=any_file)


class TestAddToEnv:
def test_add_twice(
self,
Expand Down Expand Up @@ -116,7 +124,7 @@ def test_correct_umask(
with SingularitySandbox(base_image=data_cached_alpine_sif) as sandbox:
# Test file permissions
env_file = sandbox.sandbox_dir / ".singularity.d/env/92-cotainr-env.sh"
sandbox._create_file(env_file=env_file)
sandbox._create_file(f=env_file)
assert env_file.exists()
test_file_mode = env_file.stat().st_mode
# file permissions extracted from the last 3 octal digits of st_mode
Expand Down

0 comments on commit 9865469

Please sign in to comment.