コード例 #1
0
def test_implementation_checking(AbstractStuff):
    class StuffDoer(AbstractStuff):
        pass

    py.test.raises(ImplementationError,
                   lambda: AbstractStuff.register(StuffDoer))
    _reset_registry()
コード例 #2
0
def test_register(AbstractStuff):
    class StuffDoer(AbstractStuff):
        def do_stuff(self):
            return True
    AbstractStuff.register(StuffDoer)
    stuffs = list(AbstractStuff)
    assert len(stuffs) == 1
    assert stuffs[0] is StuffDoer
    _reset_registry()
コード例 #3
0
def test_register(AbstractStuff):
    class StuffDoer(AbstractStuff):
        def do_stuff(self):
            return True

    AbstractStuff.register(StuffDoer)
    stuffs = list(AbstractStuff)
    assert len(stuffs) == 1
    assert stuffs[0] is StuffDoer
    _reset_registry()
コード例 #4
0
def test_register_multiple_interfaces(AbstractStuff):
    class StuffDoer(AbstractStuff):
        def do_stuff(self):
            return True
    AbstractStuff.register(StuffDoer)

    class AbstractMoreStuff(AbstractStuff):
        @abstractmethod
        def do_more_stuff(self):
            pass
    class MoreStuffDoer(AbstractMoreStuff):
        def do_stuff(self):
            return True
        def do_more_stuff(self):
            return True
    AbstractMoreStuff.register(MoreStuffDoer)

    assert set(AbstractStuff) == set([StuffDoer, MoreStuffDoer])
    assert set(AbstractMoreStuff) == set([MoreStuffDoer])
    _reset_registry()
コード例 #5
0
def test_register_multiple_interfaces(AbstractStuff):
    class StuffDoer(AbstractStuff):
        def do_stuff(self):
            return True

    AbstractStuff.register(StuffDoer)

    class AbstractMoreStuff(AbstractStuff):
        @abstractmethod
        def do_more_stuff(self):
            pass

    class MoreStuffDoer(AbstractMoreStuff):
        def do_stuff(self):
            return True

        def do_more_stuff(self):
            return True

    AbstractMoreStuff.register(MoreStuffDoer)

    assert set(AbstractStuff) == set([StuffDoer, MoreStuffDoer])
    assert set(AbstractMoreStuff) == set([MoreStuffDoer])
    _reset_registry()
コード例 #6
0
def test_implementation_checking(AbstractStuff):
    class StuffDoer(AbstractStuff):
        pass
    py.test.raises(ImplementationError, lambda: AbstractStuff.register(StuffDoer))
    _reset_registry()
コード例 #7
0
ファイル: test_abc.py プロジェクト: greentv/mediacore
 def tearDown(self):
     from mediacore.plugin.abc import _reset_registry
     _reset_registry()
コード例 #8
0
ファイル: test_abc.py プロジェクト: greentv/mediacore
 def setUp(self):
     from mediacore.plugin.abc import _reset_registry
     _reset_registry()