Esempio n. 1
0
 def test_registry(self):
     pp = PluginManager()
     class A: pass 
     a1, a2 = A(), A()
     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)
Esempio n. 2
0
    def test_registry(self):
        pp = PluginManager()

        class A:
            pass

        a1, a2 = A(), A()
        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)
Esempio n. 3
0
 def test_register_imported_modules(self):
     pp = PluginManager()
     mod = py.std.new.module("x.y.pytest_hello")
     pp.register(mod)
     assert pp.isregistered(mod)
     assert pp.getplugins() == [mod]
     py.test.raises(AssertionError, "pp.register(mod)")
     mod2 = py.std.new.module("pytest_hello")
     #pp.register(mod2) # double registry 
     py.test.raises(AssertionError, "pp.register(mod)")
     #assert not pp.isregistered(mod2)
     assert pp.getplugins() == [mod] # does not actually modify plugins 
Esempio n. 4
0
 def test_register_imported_modules(self):
     pp = PluginManager()
     mod = py.std.new.module("x.y.pytest_hello")
     pp.register(mod)
     assert pp.isregistered(mod)
     assert pp.getplugins() == [mod]
     py.test.raises(AssertionError, "pp.register(mod)")
     mod2 = py.std.new.module("pytest_hello")
     #pp.register(mod2) # double registry
     py.test.raises(AssertionError, "pp.register(mod)")
     #assert not pp.isregistered(mod2)
     assert pp.getplugins() == [mod]  # does not actually modify plugins