def test_listattr(self):
     plugins = PytestPlugins()
     class My2:
         x = 42
     plugins.register(My2())
     assert not plugins.listattr("hello")
     assert plugins.listattr("x") == [42]
 def test_getfirst(self):
     plugins = PytestPlugins()
     class My1:
         x = 1
     assert plugins.getfirst("x") is None
     plugins.register(My1())
     assert plugins.getfirst("x") == 1
 def test_call_each(self):
     plugins = PytestPlugins()
     class My:
         def method(self, arg):
             pass
     plugins.register(My())
     py.test.raises(TypeError, 'plugins.call_each("method")')
     l = plugins.call_each("method", arg=42)
     assert l == []
     py.test.raises(TypeError, 'plugins.call_each("method", arg=42, s=13)')
 def test_registry(self):
     pp = PytestPlugins()
     a1, a2 = object(), object()
     pp.register(a1)
     assert pp.isregistered(a1)
     pp.register(a2)
     assert pp.isregistered(a2)
     assert pp.getplugins() == [a1, a2]
     pp.unregister(a1)
     assert not pp.isregistered(a1)
     pp.unregister(a2)
     assert not pp.isregistered(a2)
 def test_call_firstresult(self):
     plugins = PytestPlugins()
     class My1:
         def method(self):
             pass
     class My2:
         def method(self):
             return True 
     class My3:
         def method(self):
             return None
     assert plugins.call_firstresult("method") is None
     assert plugins.call_firstresult("methodnotexists") is None
     plugins.register(My1())
     assert plugins.call_firstresult("method") is None
     plugins.register(My2())
     assert plugins.call_firstresult("method") == True
     plugins.register(My3())
     assert plugins.call_firstresult("method") == True