Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add pytest for get_wf_files
  • Loading branch information
mirpedrol committed Aug 26, 2025
commit 691d8ac5526f8b04869aeaf89443a12b6d9a4699
16 changes: 12 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ def test_set_wd(self):

def test_set_wd_revert_on_raise(self):
wd_before_context = Path().resolve()
with pytest.raises(Exception):
with nf_core.utils.set_wd(self.tmp_dir):
raise Exception
assert wd_before_context == Path().resolve()
with mock.patch("nf_core.utils.set_wd", side_effect=Exception("mocked exception")):
with pytest.raises(Exception):
with nf_core.utils.set_wd(self.tmp_dir):
assert wd_before_context == Path().resolve()

@mock.patch("nf_core.utils.run_cmd")
def test_fetch_wf_config(self, mock_run_cmd):
Expand All @@ -224,3 +224,11 @@ def test_fetch_wf_config(self, mock_run_cmd):
config = nf_core.utils.fetch_wf_config(".", False)
assert len(config.keys()) == 1
assert "params.param2" in list(config.keys())

def test_get_wf_files(self):
files = nf_core.utils.get_wf_files(self.pipeline_obj.wf_path)
assert str(Path(self.pipeline_dir, "main.nf")) in files

def test_get_wf_files_no_gitignore(self):
files = nf_core.utils.get_wf_files(Path("random/path"))
assert files == []
Loading