-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from fractal-napari-plugins-collection/improve…
…_testing [WIP] Improve testing
- Loading branch information
Showing
7 changed files
with
241 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# enable pre-commit.ci at https://pre-commit.ci/ | ||
# it adds: | ||
# 1. auto fixing pull requests | ||
# 2. auto updating the pre-commit configuration | ||
ci: | ||
autoupdate_schedule: monthly | ||
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]" | ||
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate" | ||
|
||
repos: | ||
- repo: https://github.com/abravalheri/validate-pyproject | ||
rev: v0.12.1 | ||
hooks: | ||
- id: validate-pyproject | ||
|
||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: v0.0.257 | ||
hooks: | ||
- id: ruff | ||
args: [--fix] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.1.0 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/napari_feature_classifier/_tests/test_feature_loading.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" Tests feature loading""" | ||
import pandas as pd | ||
|
||
import imageio | ||
from pathlib import Path | ||
from napari_feature_classifier.feature_loader_widget import ( | ||
load_features_factory, | ||
) | ||
|
||
lbl_img_np = imageio.v2.imread( | ||
Path("src/napari_feature_classifier/sample_data/test_labels.tif") | ||
) | ||
csv_path = Path("src/napari_feature_classifier/sample_data/test_df.csv") | ||
|
||
|
||
def test_feature_loading_csv(make_napari_viewer, capsys): | ||
""" | ||
Tests if the main widget launches | ||
""" | ||
# make viewer and add an image layer using our fixture | ||
viewer = make_napari_viewer() | ||
labels_layer = viewer.add_labels(lbl_img_np) | ||
|
||
# Start feature loading widget | ||
loading_widget = load_features_factory() | ||
loading_widget.layer.value = labels_layer | ||
loading_widget.path.value = csv_path | ||
features = pd.read_csv(csv_path) | ||
loading_widget.__call__() | ||
assert (labels_layer.features == features).all().all() | ||
|
||
# Assert that this message is logged | ||
expected = "INFO: Loaded features and attached them " | ||
expected += 'to "lbl_img_np" layer\n' | ||
assert expected in capsys.readouterr().out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters