Skip to content

Commit

Permalink
Add a simple test of when_imagej_starts callback
Browse files Browse the repository at this point in the history
This test checks that functions registered via
when_imagej_starts get called as part of imagej.init.
  • Loading branch information
ctrueden authored and elevans committed Jun 26, 2024
1 parent 56f7f4f commit dbc6107
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def ij(request):
legacy = request.config.getoption("--legacy")
headless = request.config.getoption("--headless")

imagej.when_imagej_starts(lambda ij: setattr(ij, "_when_imagej_starts_result", "success"))

mode = "headless" if headless else "interactive"
ij = imagej.init(ij_dir, mode=mode, add_legacy=legacy)

Expand Down
7 changes: 7 additions & 0 deletions tests/test_callbacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def test_when_imagej_starts(ij):
"""
The ImageJ2 gateway test fixture registers a callback function via
when_imagej_starts, which injects a small piece of data into the gateway
object. We check for that data here to make sure the callback happened.
"""
assert "success" == getattr(ij, "_when_imagej_starts_result", None)

0 comments on commit dbc6107

Please sign in to comment.