mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 19:14:00 +03:00
Fix PEP257 D211 error
This commit is contained in:
parent
b7bab4938f
commit
8ab0cc5e0e
|
@ -71,7 +71,6 @@ Examples
|
||||||
|
|
||||||
|
|
||||||
class ObjectA(object):
|
class ObjectA(object):
|
||||||
|
|
||||||
"""Example class ObjectA, that has dependency on database."""
|
"""Example class ObjectA, that has dependency on database."""
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
|
@ -80,7 +79,6 @@ Examples
|
||||||
|
|
||||||
|
|
||||||
class ObjectB(object):
|
class ObjectB(object):
|
||||||
|
|
||||||
"""Example class ObjectB, that has dependencies on ObjectA and database."""
|
"""Example class ObjectB, that has dependencies on ObjectA and database."""
|
||||||
|
|
||||||
def __init__(self, a, db):
|
def __init__(self, a, db):
|
||||||
|
@ -90,7 +88,6 @@ Examples
|
||||||
|
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Catalog of providers."""
|
"""Catalog of providers."""
|
||||||
|
|
||||||
database = di.Singleton(sqlite3.Connection,
|
database = di.Singleton(sqlite3.Connection,
|
||||||
|
|
|
@ -9,7 +9,6 @@ from .utils import is_catalog
|
||||||
|
|
||||||
|
|
||||||
class CatalogMetaClass(type):
|
class CatalogMetaClass(type):
|
||||||
|
|
||||||
"""Providers catalog meta class."""
|
"""Providers catalog meta class."""
|
||||||
|
|
||||||
def __new__(mcs, class_name, bases, attributes):
|
def __new__(mcs, class_name, bases, attributes):
|
||||||
|
@ -35,7 +34,6 @@ class CatalogMetaClass(type):
|
||||||
|
|
||||||
@six.add_metaclass(CatalogMetaClass)
|
@six.add_metaclass(CatalogMetaClass)
|
||||||
class AbstractCatalog(object):
|
class AbstractCatalog(object):
|
||||||
|
|
||||||
"""Abstract providers catalog.
|
"""Abstract providers catalog.
|
||||||
|
|
||||||
:type providers: dict[str, dependency_injector.Provider]
|
:type providers: dict[str, dependency_injector.Provider]
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
|
|
||||||
"""Base error."""
|
"""Base error."""
|
||||||
|
|
|
@ -18,7 +18,6 @@ else: # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
class Injection(object):
|
class Injection(object):
|
||||||
|
|
||||||
"""Base injection class."""
|
"""Base injection class."""
|
||||||
|
|
||||||
__IS_INJECTION__ = True
|
__IS_INJECTION__ = True
|
||||||
|
@ -38,21 +37,18 @@ class Injection(object):
|
||||||
|
|
||||||
|
|
||||||
class KwArg(Injection):
|
class KwArg(Injection):
|
||||||
|
|
||||||
"""Keyword argument injection."""
|
"""Keyword argument injection."""
|
||||||
|
|
||||||
__IS_KWARG_INJECTION__ = True
|
__IS_KWARG_INJECTION__ = True
|
||||||
|
|
||||||
|
|
||||||
class Attribute(Injection):
|
class Attribute(Injection):
|
||||||
|
|
||||||
"""Attribute injection."""
|
"""Attribute injection."""
|
||||||
|
|
||||||
__IS_ATTRIBUTE_INJECTION__ = True
|
__IS_ATTRIBUTE_INJECTION__ = True
|
||||||
|
|
||||||
|
|
||||||
class Method(Injection):
|
class Method(Injection):
|
||||||
|
|
||||||
"""Method injection."""
|
"""Method injection."""
|
||||||
|
|
||||||
__IS_METHOD_INJECTION__ = True
|
__IS_METHOD_INJECTION__ = True
|
||||||
|
|
|
@ -15,7 +15,6 @@ from .errors import Error
|
||||||
|
|
||||||
|
|
||||||
class Provider(object):
|
class Provider(object):
|
||||||
|
|
||||||
"""Base provider class."""
|
"""Base provider class."""
|
||||||
|
|
||||||
__IS_PROVIDER__ = True
|
__IS_PROVIDER__ = True
|
||||||
|
@ -76,7 +75,6 @@ class Provider(object):
|
||||||
|
|
||||||
|
|
||||||
class Delegate(Provider):
|
class Delegate(Provider):
|
||||||
|
|
||||||
"""Provider's delegate."""
|
"""Provider's delegate."""
|
||||||
|
|
||||||
__slots__ = ('delegated',)
|
__slots__ = ('delegated',)
|
||||||
|
@ -95,7 +93,6 @@ class Delegate(Provider):
|
||||||
|
|
||||||
|
|
||||||
class Factory(Provider):
|
class Factory(Provider):
|
||||||
|
|
||||||
"""Factory provider.
|
"""Factory provider.
|
||||||
|
|
||||||
Factory provider creates new instance of specified class on every call.
|
Factory provider creates new instance of specified class on every call.
|
||||||
|
@ -142,7 +139,6 @@ class Factory(Provider):
|
||||||
|
|
||||||
|
|
||||||
class Singleton(Provider):
|
class Singleton(Provider):
|
||||||
|
|
||||||
"""Singleton provider.
|
"""Singleton provider.
|
||||||
|
|
||||||
Singleton provider will create instance once and return it on every call.
|
Singleton provider will create instance once and return it on every call.
|
||||||
|
@ -169,7 +165,6 @@ class Singleton(Provider):
|
||||||
|
|
||||||
|
|
||||||
class ExternalDependency(Provider):
|
class ExternalDependency(Provider):
|
||||||
|
|
||||||
"""External dependency provider.
|
"""External dependency provider.
|
||||||
|
|
||||||
Those provider is used when dependency obviously have to be overridden by
|
Those provider is used when dependency obviously have to be overridden by
|
||||||
|
@ -205,7 +200,6 @@ class ExternalDependency(Provider):
|
||||||
|
|
||||||
|
|
||||||
class StaticProvider(Provider):
|
class StaticProvider(Provider):
|
||||||
|
|
||||||
"""Static provider.
|
"""Static provider.
|
||||||
|
|
||||||
Static provider is base implementation that provides exactly the same as
|
Static provider is base implementation that provides exactly the same as
|
||||||
|
@ -225,27 +219,22 @@ class StaticProvider(Provider):
|
||||||
|
|
||||||
|
|
||||||
class Class(StaticProvider):
|
class Class(StaticProvider):
|
||||||
|
|
||||||
"""Class provider provides class."""
|
"""Class provider provides class."""
|
||||||
|
|
||||||
|
|
||||||
class Object(StaticProvider):
|
class Object(StaticProvider):
|
||||||
|
|
||||||
"""Object provider provides object."""
|
"""Object provider provides object."""
|
||||||
|
|
||||||
|
|
||||||
class Function(StaticProvider):
|
class Function(StaticProvider):
|
||||||
|
|
||||||
"""Function provider provides function."""
|
"""Function provider provides function."""
|
||||||
|
|
||||||
|
|
||||||
class Value(StaticProvider):
|
class Value(StaticProvider):
|
||||||
|
|
||||||
"""Value provider provides value."""
|
"""Value provider provides value."""
|
||||||
|
|
||||||
|
|
||||||
class Callable(Provider):
|
class Callable(Provider):
|
||||||
|
|
||||||
"""Callable provider.
|
"""Callable provider.
|
||||||
|
|
||||||
Callable provider provides callable that is called on every provider call
|
Callable provider provides callable that is called on every provider call
|
||||||
|
@ -270,7 +259,6 @@ class Callable(Provider):
|
||||||
|
|
||||||
|
|
||||||
class Config(Provider):
|
class Config(Provider):
|
||||||
|
|
||||||
"""Config provider.
|
"""Config provider.
|
||||||
|
|
||||||
Config provider provides dict values. Also config provider creates
|
Config provider provides dict values. Also config provider creates
|
||||||
|
@ -309,7 +297,6 @@ class Config(Provider):
|
||||||
|
|
||||||
|
|
||||||
class ChildConfig(Provider):
|
class ChildConfig(Provider):
|
||||||
|
|
||||||
"""Child config provider.
|
"""Child config provider.
|
||||||
|
|
||||||
Child config provide an value from the root config object according to
|
Child config provide an value from the root config object according to
|
||||||
|
|
|
@ -7,7 +7,6 @@ from dependency_injector.injections import KwArg
|
||||||
|
|
||||||
|
|
||||||
class ObjectA(object):
|
class ObjectA(object):
|
||||||
|
|
||||||
"""Example class ObjectA, that has dependencies on some setting values."""
|
"""Example class ObjectA, that has dependencies on some setting values."""
|
||||||
|
|
||||||
def __init__(self, fee, price, timezone):
|
def __init__(self, fee, price, timezone):
|
||||||
|
@ -18,7 +17,6 @@ class ObjectA(object):
|
||||||
|
|
||||||
|
|
||||||
class Catalog(AbstractCatalog):
|
class Catalog(AbstractCatalog):
|
||||||
|
|
||||||
"""Catalog of dependency_injector providers."""
|
"""Catalog of dependency_injector providers."""
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
|
|
@ -18,7 +18,6 @@ app = flask.Flask(__name__)
|
||||||
@di.inject(database=database)
|
@di.inject(database=database)
|
||||||
@di.inject(some_setting=777)
|
@di.inject(some_setting=777)
|
||||||
class HelloView(flask.views.View):
|
class HelloView(flask.views.View):
|
||||||
|
|
||||||
"""Example flask class-based view."""
|
"""Example flask class-based view."""
|
||||||
|
|
||||||
def __init__(self, database, some_setting):
|
def __init__(self, database, some_setting):
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class CatalogA(di.AbstractCatalog):
|
class CatalogA(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Example catalog A."""
|
"""Example catalog A."""
|
||||||
|
|
||||||
provider1 = di.Factory(object)
|
provider1 = di.Factory(object)
|
||||||
|
@ -12,7 +11,6 @@ class CatalogA(di.AbstractCatalog):
|
||||||
|
|
||||||
|
|
||||||
class CatalogB(CatalogA):
|
class CatalogB(CatalogA):
|
||||||
|
|
||||||
"""Example catalog B."""
|
"""Example catalog B."""
|
||||||
|
|
||||||
provider2 = di.Singleton(object)
|
provider2 = di.Singleton(object)
|
||||||
|
|
|
@ -11,7 +11,6 @@ ExtendedObject2 = collections.namedtuple('ExtendedObject2', [])
|
||||||
|
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Providers catalog."""
|
"""Providers catalog."""
|
||||||
|
|
||||||
object1_factory = di.Factory(Object1,
|
object1_factory = di.Factory(Object1,
|
||||||
|
@ -25,7 +24,6 @@ class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
|
|
||||||
class AnotherCatalog(di.AbstractCatalog):
|
class AnotherCatalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Another providers catalog."""
|
"""Another providers catalog."""
|
||||||
|
|
||||||
object2_factory = di.Factory(ExtendedObject2)
|
object2_factory = di.Factory(ExtendedObject2)
|
||||||
|
|
|
@ -11,7 +11,6 @@ ExtendedObject2 = collections.namedtuple('ExtendedObject2', [])
|
||||||
|
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Providers catalog."""
|
"""Providers catalog."""
|
||||||
|
|
||||||
object1_factory = di.Factory(Object1,
|
object1_factory = di.Factory(Object1,
|
||||||
|
@ -27,7 +26,6 @@ class Catalog(di.AbstractCatalog):
|
||||||
# Overriding `Catalog` with `AnotherCatalog`:
|
# Overriding `Catalog` with `AnotherCatalog`:
|
||||||
@di.override(Catalog)
|
@di.override(Catalog)
|
||||||
class AnotherCatalog(di.AbstractCatalog):
|
class AnotherCatalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Another providers catalog."""
|
"""Another providers catalog."""
|
||||||
|
|
||||||
object2_factory = di.Factory(ExtendedObject2)
|
object2_factory = di.Factory(ExtendedObject2)
|
||||||
|
|
|
@ -10,7 +10,6 @@ Object2 = collections.namedtuple('Object2', ['object1'])
|
||||||
|
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Providers catalog."""
|
"""Providers catalog."""
|
||||||
|
|
||||||
object1_factory = di.Factory(Object1,
|
object1_factory = di.Factory(Object1,
|
||||||
|
|
|
@ -5,7 +5,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class ObjectA(object):
|
class ObjectA(object):
|
||||||
|
|
||||||
"""Example class ObjectA, that has dependency on database."""
|
"""Example class ObjectA, that has dependency on database."""
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
|
@ -14,7 +13,6 @@ class ObjectA(object):
|
||||||
|
|
||||||
|
|
||||||
class ObjectB(object):
|
class ObjectB(object):
|
||||||
|
|
||||||
"""Example class ObjectB, that has dependencies on ObjectA and database."""
|
"""Example class ObjectB, that has dependencies on ObjectA and database."""
|
||||||
|
|
||||||
def __init__(self, a, db):
|
def __init__(self, a, db):
|
||||||
|
@ -24,7 +22,6 @@ class ObjectB(object):
|
||||||
|
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Catalog of providers."""
|
"""Catalog of providers."""
|
||||||
|
|
||||||
database = di.Singleton(sqlite3.Connection,
|
database = di.Singleton(sqlite3.Connection,
|
||||||
|
|
|
@ -4,12 +4,10 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
|
|
||||||
class UsersFactory(di.Provider):
|
class UsersFactory(di.Provider):
|
||||||
|
|
||||||
"""Example users factory."""
|
"""Example users factory."""
|
||||||
|
|
||||||
__slots__ = ('_factory',)
|
__slots__ = ('_factory',)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class UserService(object):
|
class UserService(object):
|
||||||
|
|
||||||
"""Example class UserService.
|
"""Example class UserService.
|
||||||
|
|
||||||
UserService has dependency on DBAPI 2.0 database connection.
|
UserService has dependency on DBAPI 2.0 database connection.
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
# Factory provider creates new instance of specified class on every call.
|
# Factory provider creates new instance of specified class on every call.
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -14,12 +13,10 @@ class User(object):
|
||||||
|
|
||||||
|
|
||||||
class Photo(object):
|
class Photo(object):
|
||||||
|
|
||||||
"""Example class Photo."""
|
"""Example class Photo."""
|
||||||
|
|
||||||
|
|
||||||
class CreditCard(object):
|
class CreditCard(object):
|
||||||
|
|
||||||
"""Example class CreditCard."""
|
"""Example class CreditCard."""
|
||||||
|
|
||||||
# User, Photo and CreditCard factories:
|
# User, Photo and CreditCard factories:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
def __init__(self, photos_factory):
|
def __init__(self, photos_factory):
|
||||||
|
@ -25,7 +24,6 @@ class User(object):
|
||||||
|
|
||||||
|
|
||||||
class Photo(object):
|
class Photo(object):
|
||||||
|
|
||||||
"""Example class Photo."""
|
"""Example class Photo."""
|
||||||
|
|
||||||
# User and Photo factories:
|
# User and Photo factories:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
def __init__(self, main_photo):
|
def __init__(self, main_photo):
|
||||||
|
@ -14,7 +13,6 @@ class User(object):
|
||||||
|
|
||||||
|
|
||||||
class Photo(object):
|
class Photo(object):
|
||||||
|
|
||||||
"""Example class Photo."""
|
"""Example class Photo."""
|
||||||
|
|
||||||
# User and Photo factories:
|
# User and Photo factories:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User.
|
"""Example class User.
|
||||||
|
|
||||||
Class User has to be provided with user id.
|
Class User has to be provided with user id.
|
||||||
|
@ -24,12 +23,10 @@ class User(object):
|
||||||
|
|
||||||
|
|
||||||
class Photo(object):
|
class Photo(object):
|
||||||
|
|
||||||
"""Example class Photo."""
|
"""Example class Photo."""
|
||||||
|
|
||||||
|
|
||||||
class CreditCard(object):
|
class CreditCard(object):
|
||||||
|
|
||||||
"""Example class CreditCard."""
|
"""Example class CreditCard."""
|
||||||
|
|
||||||
# User, Photo and CreditCard factories:
|
# User, Photo and CreditCard factories:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -22,12 +21,10 @@ class User(object):
|
||||||
|
|
||||||
|
|
||||||
class Photo(object):
|
class Photo(object):
|
||||||
|
|
||||||
"""Example class Photo."""
|
"""Example class Photo."""
|
||||||
|
|
||||||
|
|
||||||
class CreditCard(object):
|
class CreditCard(object):
|
||||||
|
|
||||||
"""Example class CreditCard."""
|
"""Example class CreditCard."""
|
||||||
|
|
||||||
# User, Photo and CreditCard factories:
|
# User, Photo and CreditCard factories:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
# Users factory:
|
# Users factory:
|
||||||
|
@ -21,7 +20,6 @@ assert isinstance(user1, User) and isinstance(user2, User)
|
||||||
|
|
||||||
# Extending User:
|
# Extending User:
|
||||||
class SuperUser(User):
|
class SuperUser(User):
|
||||||
|
|
||||||
"""Example class SuperUser."""
|
"""Example class SuperUser."""
|
||||||
|
|
||||||
# Overriding users factory:
|
# Overriding users factory:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
def __init__(self, id, password):
|
def __init__(self, id, password):
|
||||||
|
@ -15,7 +14,6 @@ class User(object):
|
||||||
|
|
||||||
|
|
||||||
class UserService(object):
|
class UserService(object):
|
||||||
|
|
||||||
"""Example class UserService."""
|
"""Example class UserService."""
|
||||||
|
|
||||||
def __init__(self, user_cls):
|
def __init__(self, user_cls):
|
||||||
|
@ -50,7 +48,6 @@ assert user1 is not user2
|
||||||
|
|
||||||
|
|
||||||
class ExtendedUser(User):
|
class ExtendedUser(User):
|
||||||
|
|
||||||
"""Example class ExtendedUser."""
|
"""Example class ExtendedUser."""
|
||||||
|
|
||||||
def __init__(self, id, password, first_name=None, last_name=None,
|
def __init__(self, id, password, first_name=None, last_name=None,
|
||||||
|
@ -63,7 +60,6 @@ class ExtendedUser(User):
|
||||||
|
|
||||||
|
|
||||||
class ExtendedUserService(UserService):
|
class ExtendedUserService(UserService):
|
||||||
|
|
||||||
"""Example class ExtendedUserService."""
|
"""Example class ExtendedUserService."""
|
||||||
|
|
||||||
def get_by_id(self, id):
|
def get_by_id(self, id):
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class UserService(object):
|
class UserService(object):
|
||||||
|
|
||||||
"""Example class UserService."""
|
"""Example class UserService."""
|
||||||
|
|
||||||
# Singleton provider creates new instance of specified class on first call and
|
# Singleton provider creates new instance of specified class on first call and
|
||||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class UserService(object):
|
class UserService(object):
|
||||||
|
|
||||||
"""Example class UserService."""
|
"""Example class UserService."""
|
||||||
|
|
||||||
# Users service singleton provider:
|
# Users service singleton provider:
|
||||||
|
|
|
@ -5,25 +5,21 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class CatalogsInheritanceTests(unittest.TestCase):
|
class CatalogsInheritanceTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Catalogs inheritance tests."""
|
"""Catalogs inheritance tests."""
|
||||||
|
|
||||||
class CatalogA(di.AbstractCatalog):
|
class CatalogA(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Test catalog A."""
|
"""Test catalog A."""
|
||||||
|
|
||||||
p11 = di.Provider()
|
p11 = di.Provider()
|
||||||
p12 = di.Provider()
|
p12 = di.Provider()
|
||||||
|
|
||||||
class CatalogB(CatalogA):
|
class CatalogB(CatalogA):
|
||||||
|
|
||||||
"""Test catalog B."""
|
"""Test catalog B."""
|
||||||
|
|
||||||
p21 = di.Provider()
|
p21 = di.Provider()
|
||||||
p22 = di.Provider()
|
p22 = di.Provider()
|
||||||
|
|
||||||
class CatalogC(CatalogB):
|
class CatalogC(CatalogB):
|
||||||
|
|
||||||
"""Test catalog C."""
|
"""Test catalog C."""
|
||||||
|
|
||||||
p31 = di.Provider()
|
p31 = di.Provider()
|
||||||
|
@ -73,11 +69,9 @@ class CatalogsInheritanceTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class CatalogTests(unittest.TestCase):
|
class CatalogTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Catalog test cases."""
|
"""Catalog test cases."""
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Test catalog."""
|
"""Test catalog."""
|
||||||
|
|
||||||
obj = di.Object(object())
|
obj = di.Object(object())
|
||||||
|
@ -100,11 +94,9 @@ class CatalogTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class OverrideTests(unittest.TestCase):
|
class OverrideTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Override decorator test cases."""
|
"""Override decorator test cases."""
|
||||||
|
|
||||||
class Catalog(di.AbstractCatalog):
|
class Catalog(di.AbstractCatalog):
|
||||||
|
|
||||||
"""Test catalog."""
|
"""Test catalog."""
|
||||||
|
|
||||||
obj = di.Object(object())
|
obj = di.Object(object())
|
||||||
|
@ -114,7 +106,6 @@ class OverrideTests(unittest.TestCase):
|
||||||
"""Test catalog overriding with another catalog."""
|
"""Test catalog overriding with another catalog."""
|
||||||
@di.override(self.Catalog)
|
@di.override(self.Catalog)
|
||||||
class OverridingCatalog(self.Catalog):
|
class OverridingCatalog(self.Catalog):
|
||||||
|
|
||||||
"""Overriding catalog."""
|
"""Overriding catalog."""
|
||||||
|
|
||||||
obj = di.Value(1)
|
obj = di.Value(1)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class InjectionTests(unittest.TestCase):
|
class InjectionTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Injection test cases."""
|
"""Injection test cases."""
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
|
@ -26,7 +25,6 @@ class InjectionTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class KwArgTests(unittest.TestCase):
|
class KwArgTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Keyword arg injection test cases."""
|
"""Keyword arg injection test cases."""
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
|
@ -37,7 +35,6 @@ class KwArgTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class AttributeTests(unittest.TestCase):
|
class AttributeTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Attribute injection test cases."""
|
"""Attribute injection test cases."""
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
|
@ -48,7 +45,6 @@ class AttributeTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class MethodTests(unittest.TestCase):
|
class MethodTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Method injection test cases."""
|
"""Method injection test cases."""
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
|
@ -59,7 +55,6 @@ class MethodTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class InjectTests(unittest.TestCase):
|
class InjectTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Inject decorator test cases."""
|
"""Inject decorator test cases."""
|
||||||
|
|
||||||
def test_decorated(self):
|
def test_decorated(self):
|
||||||
|
@ -155,7 +150,6 @@ class InjectTests(unittest.TestCase):
|
||||||
def test_decorate_class_method(self):
|
def test_decorate_class_method(self):
|
||||||
"""Test `inject()` decorator with class method."""
|
"""Test `inject()` decorator with class method."""
|
||||||
class Test(object):
|
class Test(object):
|
||||||
|
|
||||||
"""Test class."""
|
"""Test class."""
|
||||||
|
|
||||||
@di.inject(arg1=123)
|
@di.inject(arg1=123)
|
||||||
|
@ -175,7 +169,6 @@ class InjectTests(unittest.TestCase):
|
||||||
@di.inject(arg1=123)
|
@di.inject(arg1=123)
|
||||||
@di.inject(arg2=456)
|
@di.inject(arg2=456)
|
||||||
class Test(object):
|
class Test(object):
|
||||||
|
|
||||||
"""Test class."""
|
"""Test class."""
|
||||||
|
|
||||||
def __init__(self, arg1, arg2):
|
def __init__(self, arg1, arg2):
|
||||||
|
@ -193,5 +186,4 @@ class InjectTests(unittest.TestCase):
|
||||||
with self.assertRaises(di.Error):
|
with self.assertRaises(di.Error):
|
||||||
@di.inject(arg1=123)
|
@di.inject(arg1=123)
|
||||||
class Test(object):
|
class Test(object):
|
||||||
|
|
||||||
"""Test class."""
|
"""Test class."""
|
||||||
|
|
|
@ -5,7 +5,6 @@ import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class ProviderTests(unittest.TestCase):
|
class ProviderTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Provider test cases."""
|
"""Provider test cases."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -106,7 +105,6 @@ class ProviderTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class DelegateTests(unittest.TestCase):
|
class DelegateTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Delegate test cases."""
|
"""Delegate test cases."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -132,11 +130,9 @@ class DelegateTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class FactoryTests(unittest.TestCase):
|
class FactoryTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Factory test cases."""
|
"""Factory test cases."""
|
||||||
|
|
||||||
class Example(object):
|
class Example(object):
|
||||||
|
|
||||||
"""Example class for Factory provider tests."""
|
"""Example class for Factory provider tests."""
|
||||||
|
|
||||||
def __init__(self, init_arg1=None, init_arg2=None):
|
def __init__(self, init_arg1=None, init_arg2=None):
|
||||||
|
@ -317,7 +313,6 @@ class FactoryTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class SingletonTests(unittest.TestCase):
|
class SingletonTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Singleton test cases."""
|
"""Singleton test cases."""
|
||||||
|
|
||||||
def test_call(self):
|
def test_call(self):
|
||||||
|
@ -347,7 +342,6 @@ class SingletonTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ExternalDependencyTests(unittest.TestCase):
|
class ExternalDependencyTests(unittest.TestCase):
|
||||||
|
|
||||||
"""ExternalDependency test cases."""
|
"""ExternalDependency test cases."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -378,7 +372,6 @@ class ExternalDependencyTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class StaticProvidersTests(unittest.TestCase):
|
class StaticProvidersTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Static providers test cases."""
|
"""Static providers test cases."""
|
||||||
|
|
||||||
def test_is_provider(self):
|
def test_is_provider(self):
|
||||||
|
@ -433,7 +426,6 @@ class StaticProvidersTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class CallableTests(unittest.TestCase):
|
class CallableTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Callable test cases."""
|
"""Callable test cases."""
|
||||||
|
|
||||||
def example(self, arg1, arg2, arg3):
|
def example(self, arg1, arg2, arg3):
|
||||||
|
@ -485,7 +477,6 @@ class CallableTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ConfigTests(unittest.TestCase):
|
class ConfigTests(unittest.TestCase):
|
||||||
|
|
||||||
"""Config test cases."""
|
"""Config test cases."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user