Remove copying functionality from dynamic catalog

This commit is contained in:
Roman Mogilatov 2016-04-10 17:02:01 +03:00
parent f89ba4c5a9
commit b4b93b4016
2 changed files with 0 additions and 37 deletions

View File

@ -1,7 +1,5 @@
"""Dependency injector dynamic catalog module.""" """Dependency injector dynamic catalog module."""
import copy
import six import six
from dependency_injector.catalogs.bundle import CatalogBundle from dependency_injector.catalogs.bundle import CatalogBundle
@ -287,25 +285,6 @@ class DynamicCatalog(object):
del self.providers[name] del self.providers[name]
del self.provider_names[provider] del self.provider_names[provider]
def copy(self):
"""Copy catalog instance and return it.
:rtype: py:class:`DynamicCatalog`
:return: Copied catalog.
"""
return copy.copy(self)
def deepcopy(self, memo=None):
"""Copy catalog instance and it's providers and return it.
:param memo: Memorized instances
:type memo: dict[int, object]
:rtype: py:class:`DynamicCatalog`
:return: Copied catalog.
"""
return copy.deepcopy(self, memo)
def __getattr__(self, name): def __getattr__(self, name):
"""Return provider with specified name or raise en error. """Return provider with specified name or raise en error.

View File

@ -212,22 +212,6 @@ class DynamicCatalogTests(unittest.TestCase):
self.assertTrue(len(self.catalog.filter(providers.Provider)) == 2) self.assertTrue(len(self.catalog.filter(providers.Provider)) == 2)
self.assertTrue(len(self.catalog.filter(providers.Value)) == 0) self.assertTrue(len(self.catalog.filter(providers.Value)) == 0)
def test_copy(self):
"""Test copying of catalog."""
catalog_copy = self.catalog.copy()
self.assertIsNot(self.catalog, catalog_copy)
self.assertIs(self.catalog.p1, catalog_copy.p1)
self.assertIs(self.catalog.p2, catalog_copy.p2)
def test_deepcopy(self):
"""Test copying of catalog."""
catalog_copy = self.catalog.deepcopy()
self.assertIsNot(self.catalog, catalog_copy)
self.assertIsNot(self.catalog.p1, catalog_copy.p1)
self.assertIsNot(self.catalog.p2, catalog_copy.p2)
def test_repr(self): def test_repr(self):
"""Test catalog representation.""" """Test catalog representation."""
self.assertIn('TestCatalog', repr(self.catalog)) self.assertIn('TestCatalog', repr(self.catalog))