Skip to content

Commit

Permalink
Pop registered types to prevent side effects
Browse files Browse the repository at this point in the history
  • Loading branch information
gselzer committed Jan 25, 2022
1 parent 70091e9 commit d092e07
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions tests/test_magicgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,24 @@ class Sub(Base):
register_type(int, return_callback=check_value)
register_type(Base, return_callback=check_value)

@magicgui
def func(a=1) -> int:
return a

func()
with pytest.raises(AssertionError):
func(3)
try:
@magicgui
def func(a=1) -> int:
return a

@magicgui
def func2(a=1) -> Sub:
return a

func2()
func()
with pytest.raises(AssertionError):
func(3)

@magicgui
def func2(a=1) -> Sub:
return a

func2()
finally:
from magicgui.type_map import _RETURN_CALLBACKS
_RETURN_CALLBACKS.pop(int)
_RETURN_CALLBACKS.pop(Base)


# @pytest.mark.skip(reason="need to rethink how to test this")
Expand Down

0 comments on commit d092e07

Please sign in to comment.