Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class IFakeDriver2(Interface):
""" Another fake marker interface"""
@implementer(IFakeDriver2)
class FakeDriver2:
""" Another fake driver """
def __init__(self, driver):
self.driver = driver
fake_driver = FakeDriver(None)
fake_driver2 = FakeDriver2(None)
registerDriver(IFakeDriver, FakeDriver)
registerDriver(IFakeDriver2, IFakeDriver2)
# driver implementation available after registerDriver
adapted_driver = IDriver(fake_driver)
adapted_driver2 = IDriver(fake_driver2)
# same instance of adapted_driver
assert isinstance(adapted_driver, FakeDriver)
assert isinstance(adapted_driver2, FakeDriver2)
self.driver = driver
class IFakeDriver2(Interface):
""" Another fake marker interface"""
@implementer(IFakeDriver2)
class FakeDriver2:
""" Another fake driver """
def __init__(self, driver):
self.driver = driver
fake_driver = FakeDriver(None)
fake_driver2 = FakeDriver2(None)
registerDriver(IFakeDriver, FakeDriver)
registerDriver(IFakeDriver2, IFakeDriver2)
# driver implementation available after registerDriver
adapted_driver = IDriver(fake_driver)
adapted_driver2 = IDriver(fake_driver2)
# same instance of adapted_driver
assert isinstance(adapted_driver, FakeDriver)
assert isinstance(adapted_driver2, FakeDriver2)
""" A fake marker interface"""
@implementer(IFakeDriver)
class FakeDriver:
""" A fake driver """
def __init__(self, driver):
self.driver = driver
fake_driver = FakeDriver(None)
# no register driver, look up error
with pytest.raises(TypeError):
IDriver(fake_driver)
registerDriver(IFakeDriver, FakeDriver)
# driver implementation available after registerDriver
adapted_driver = IDriver(fake_driver)
# same instance of adapted_driver
assert isinstance(adapted_driver, FakeDriver)
from zope.interface import Interface
from pypom.driver import registerDriver
from pypom.interfaces import IDriver
class IFakeDriver(Interface):
""" A fake marker interface"""
class FakeDriver:
""" A fake driver """
def __init__(self, driver):
self.driver = driver
fake_driver = FakeDriver(None)
registerDriver(IFakeDriver, FakeDriver, [FakeDriver])
# driver implementation available after registerDriver
adapted_driver = IDriver(fake_driver)
# same instance of adapted_driver
assert isinstance(adapted_driver, FakeDriver)