Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Replace arm profile with arm64 and emulate_amd64 profiles ([#3689](https://github.com/nf-core/tools/pull/3689))
- Remove workflow.trace from nf-test snapshot ([#3721](https://github.com/nf-core/tools/pull/3721))
- Add GHA to update template nf-test snapshots ([#3723](https://github.com/nf-core/tools/pull/3723))
- add pytest for get_wf_files ([#3725](https://github.com/nf-core/tools/pull/3725))

## [v3.3.2 - Tungsten Tamarin Patch 2](https://github.com/nf-core/tools/releases/tag/3.3.2) - [2025-07-08]

Expand Down
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this assertion. Doesn't this mean that the wd is the same as before and set_wd didn't do anything?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this is what the test is supposed to do, based on the name "revert_on_raise"


@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 == []