-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix parent_changed signal emission * remove useless test * increasing coverage, wip * more test coverage * fix options pop * skip events in coverage * Revert "Merge branch 'fix-parent-signal' into improve-coverage" This reverts commit c39debe, reversing changes made to f4a9521. * skip cov on tests/* * don't assert specific container margins
- Loading branch information
1 parent
c441861
commit 002f973
Showing
6 changed files
with
232 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
exclude_lines = | ||
pragma: no cover | ||
if TYPE_CHECKING: | ||
\.\.\. | ||
omit = | ||
magicgui/events.py | ||
tests/* |
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
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,49 @@ | ||
import pytest | ||
from typing_extensions import Annotated | ||
|
||
from magicgui.signature import magic_signature, make_annotated, split_annotated_type | ||
|
||
|
||
def test_make_annotated_raises(): | ||
"""Test options to annotated must be a dict.""" | ||
with pytest.raises(TypeError): | ||
make_annotated(int, "not a dict") # type: ignore | ||
|
||
|
||
def test_make_annotated_works_with_already_annotated(): | ||
"""Test that make_annotated merges options with Annotated types.""" | ||
annotated_type = Annotated[int, {"max": 10}] # type: ignore | ||
assert make_annotated(annotated_type) == annotated_type | ||
assert ( | ||
make_annotated(annotated_type, {"min": 1}) | ||
== Annotated[int, {"max": 10, "min": 1}] | ||
) | ||
|
||
|
||
def test_split_annotated_raises(): | ||
"""Test split_annotated raises on bad input.""" | ||
with pytest.raises(TypeError): | ||
split_annotated_type(int) | ||
|
||
with pytest.raises(TypeError): | ||
split_annotated_type(Annotated[int, 1]) | ||
|
||
|
||
def _sample_func(a: int, b: str = "hi"): | ||
pass | ||
|
||
|
||
def test_magic_signature_raises(): | ||
"""Test that gui_options must have keys that are params in function.""" | ||
with pytest.raises(ValueError): | ||
magic_signature(_sample_func, gui_options={"not_a_param": {"choices": []}}) | ||
|
||
|
||
def test_signature_to_container(): | ||
"""Test that a MagicSignature can make a container.""" | ||
sig = magic_signature(_sample_func, gui_options={"a": {"widget_type": "Slider"}}) | ||
container = sig.to_container() | ||
assert len(container) == 2 | ||
assert repr(container) == "<Container (a: int = 0, b: str = 'hi')>" | ||
assert repr(container.a) == "Slider(value=0, annotation=<class 'int'>, name='a')" | ||
assert repr(sig.parameters["a"]) == '<MagicParameter "a: int" {}>' |
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