Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
napari-segment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andrey ARISTOV
napari-segment
Commits
82c3a682
Commit
82c3a682
authored
2 years ago
by
Andrey Aristov
Browse files
Options
Downloads
Patches
Plain Diff
fix test
parent
500360ba
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/napari_segment/_tests/test_dock_widget.py
+0
-33
0 additions, 33 deletions
src/napari_segment/_tests/test_dock_widget.py
src/napari_segment/_tests/test_widget.py
+11
-22
11 additions, 22 deletions
src/napari_segment/_tests/test_widget.py
with
11 additions
and
55 deletions
src/napari_segment/_tests/test_dock_widget.py
deleted
100644 → 0
+
0
−
33
View file @
500360ba
from
napari_segment
import
ExampleQWidget
,
example_magic_widget
import
numpy
as
np
# make_napari_viewer is a pytest fixture that returns a napari viewer object
# capsys is a pytest fixture that captures stdout and stderr output streams
def
test_example_q_widget
(
make_napari_viewer
,
capsys
):
# make viewer and add an image layer using our fixture
viewer
=
make_napari_viewer
()
viewer
.
add_image
(
np
.
random
.
random
((
100
,
100
)))
# create our widget, passing in the viewer
my_widget
=
ExampleQWidget
(
viewer
)
# call our widget method
my_widget
.
_on_click
()
# read captured output and check that it's as we expected
captured
=
capsys
.
readouterr
()
assert
captured
.
out
==
"
napari has 1 layers
\n
"
def
test_example_magic_widget
(
make_napari_viewer
,
capsys
):
viewer
=
make_napari_viewer
()
layer
=
viewer
.
add_image
(
np
.
random
.
random
((
100
,
100
)))
# this time, our widget will be a MagicFactory or FunctionGui instance
my_widget
=
example_magic_widget
()
# if we "call" this object, it'll execute our function
my_widget
(
viewer
.
layers
[
0
])
# read captured output and check that it's as we expected
captured
=
capsys
.
readouterr
()
assert
captured
.
out
==
f
"
you have selected
{
layer
}
\n
"
This diff is collapsed.
Click to expand it.
src/napari_segment/_tests/test_widget.py
+
11
−
22
View file @
82c3a682
from
napari_segment
import
ExampleQWidget
,
example_magic_widget
from
napari_segment
import
SegmentStack
import
numpy
as
np
import
numpy
as
np
import
dask.array
as
da
# make_napari_viewer is a pytest fixture that returns a napari viewer object
# make_napari_viewer is a pytest fixture that returns a napari viewer object
# capsys is a pytest fixture that captures stdout and stderr output streams
# capsys is a pytest fixture that captures stdout and stderr output streams
def
test_
example_q_widget
(
make_napari_viewer
,
capsys
):
def
test_
segment_stack
(
make_napari_viewer
,
capsys
):
# make viewer and add an image layer using our fixture
# make viewer and add an image layer using our fixture
viewer
=
make_napari_viewer
()
viewer
=
make_napari_viewer
()
viewer
.
add_image
(
np
.
random
.
random
((
100
,
100
)))
viewer
.
add_image
(
np
.
random
.
random
((
5
,
100
,
100
))
,
name
=
"
test_data
"
,
metadata
=
{
"
path
"
:
"
fakepath.nd2
"
}
)
# create our widget, passing in the viewer
# create our widget, passing in the viewer
my_widget
=
ExampleQWidget
(
viewer
)
widget
=
SegmentStack
(
viewer
)
assert
widget
.
input
.
current_choice
==
"
test_data
"
assert
widget
.
path
==
"
fakepath.nd2
"
assert
isinstance
(
widget
.
ddata
,
da
.
Array
)
assert
widget
.
ddata
.
chunks
==
((
1
,
1
,
1
,
1
,
1
),
(
100
/
widget
.
binning
,),
(
100
/
widget
.
binning
,))
# call our widget method
my_widget
.
_on_click
()
# read captured output and check that it's as we expected
# read captured output and check that it's as we expected
captured
=
capsys
.
readouterr
()
# captured = capsys.readouterr()
assert
captured
.
out
==
"
napari has 1 layers
\n
"
# assert captured.out == "napari has 1 layers\n"
def
test_example_magic_widget
(
make_napari_viewer
,
capsys
):
viewer
=
make_napari_viewer
()
layer
=
viewer
.
add_image
(
np
.
random
.
random
((
100
,
100
)))
# this time, our widget will be a MagicFactory or FunctionGui instance
my_widget
=
example_magic_widget
()
# if we "call" this object, it'll execute our function
my_widget
(
viewer
.
layers
[
0
])
# read captured output and check that it's as we expected
captured
=
capsys
.
readouterr
()
assert
captured
.
out
==
f
"
you have selected
{
layer
}
\n
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment