From c6b79a8052f5bd39a245361bd07d1ba49f6286ac Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Tue, 15 Dec 2015 16:46:55 +0200 Subject: [PATCH] Update catalogs and providers error messages --- dependency_injector/catalogs.py | 4 ++-- dependency_injector/providers.py | 4 +--- examples/providers/factory_provided_type.py | 2 +- examples/providers/singleton_provided_type.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dependency_injector/catalogs.py b/dependency_injector/catalogs.py index 75af345d..024a19bc 100644 --- a/dependency_injector/catalogs.py +++ b/dependency_injector/catalogs.py @@ -336,8 +336,8 @@ class DynamicCatalog(object): if (self.__class__.provider_type and not isinstance(provider, self.__class__.provider_type)): - raise Error('{0} can contaon only {1} instances'.format( - self.name, self.__class__.provider_type)) + raise Error('{0} can contain only {1} instances'.format( + self, self.__class__.provider_type)) if name in self.providers: raise Error('Catalog {0} already has provider with ' diff --git a/dependency_injector/providers.py b/dependency_injector/providers.py index 9c2c6051..73440d5d 100644 --- a/dependency_injector/providers.py +++ b/dependency_injector/providers.py @@ -407,9 +407,7 @@ class Factory(Callable): if (self.__class__.provided_type and not issubclass(provides, self.__class__.provided_type)): raise Error('{0} can provide only {1} instances'.format( - '.'.join((self.__class__.__module__, - self.__class__.__name__)), - self.__class__.provided_type)) + self.__class__, self.__class__.provided_type)) self.attributes = tuple(injection for injection in args diff --git a/examples/providers/factory_provided_type.py b/examples/providers/factory_provided_type.py index 4a7ca8f0..506db636 100644 --- a/examples/providers/factory_provided_type.py +++ b/examples/providers/factory_provided_type.py @@ -31,5 +31,5 @@ try: some_service_provider = ServiceProvider(object) except errors.Error as exception: print exception - # __main__.ServiceProvider can provide only + # can provide only # instances diff --git a/examples/providers/singleton_provided_type.py b/examples/providers/singleton_provided_type.py index 17628cd3..b29e1f86 100644 --- a/examples/providers/singleton_provided_type.py +++ b/examples/providers/singleton_provided_type.py @@ -31,5 +31,5 @@ try: some_service_provider = ServiceProvider(object) except errors.Error as exception: print exception - # __main__.ServiceProvider can provide only + # can provide only # instances