def test_project_adapts_to_i_tree_node(self): my_project = MyProject() view = MyView() view.tree_node = my_project adapted = view.tree_node check_implements(type(adapted), ITreeNode)
def test_single_interface(self): """ single interface """ class IFoo(Interface): x = Int # A class that *does* implement the interface. @provides(IFoo) class Foo(HasTraits): x = Int # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, IFoo, 2)
def test_non_traits_class(self): """ non-traits class """ class IFoo(Interface): def foo(self): pass # A class that *does* implement the interface. @provides(IFoo) class Foo(object): def foo(self): pass # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, IFoo, 2)
def test_single_interface(self): """ single interface """ class IFoo(Interface): x = Int # A class that *does* implement the interface. @provides(IFoo) class Foo(HasTraits): x = Int # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, IFoo, 2) return
def test_non_traits_class(self): """ non-traits class """ class IFoo(Interface): def foo(self): pass # A class that *does* implement the interface. @provides(IFoo) class Foo(object): def foo(self): pass # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, IFoo, 2) return
def test_inherited_interfaces(self): """ inherited interfaces """ class IFoo(Interface): x = Int class IBar(IFoo): y = Int class IBaz(IBar): z = Int # A class that *does* implement the interface. @provides(IBaz) class Foo(HasTraits): x = Int y = Int z = Int # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, IBaz, 2)
def test_multiple_interfaces(self): """ multiple interfaces """ class IFoo(Interface): x = Int class IBar(Interface): y = Int class IBaz(Interface): z = Int # A class that *does* implement the interface. @provides(IFoo, IBar, IBaz) class Foo(HasTraits): x = Int y = Int z = Int # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, [IFoo, IBar, IBaz], 2) return
def test_inherited_interfaces(self): """ inherited interfaces """ class IFoo(Interface): x = Int class IBar(IFoo): y = Int class IBaz(IBar): z = Int # A class that *does* implement the interface. @provides(IBaz) class Foo(HasTraits): x = Int y = Int z = Int # The checker will raise an exception if the class does not implement # the interface. check_implements(Foo, IBaz, 2) return