mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Remove copying functionality from dynamic catalog
This commit is contained in:
parent
f89ba4c5a9
commit
b4b93b4016
|
@ -1,7 +1,5 @@
|
|||
"""Dependency injector dynamic catalog module."""
|
||||
|
||||
import copy
|
||||
|
||||
import six
|
||||
|
||||
from dependency_injector.catalogs.bundle import CatalogBundle
|
||||
|
@ -287,25 +285,6 @@ class DynamicCatalog(object):
|
|||
del self.providers[name]
|
||||
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):
|
||||
"""Return provider with specified name or raise en error.
|
||||
|
||||
|
|
|
@ -212,22 +212,6 @@ class DynamicCatalogTests(unittest.TestCase):
|
|||
self.assertTrue(len(self.catalog.filter(providers.Provider)) == 2)
|
||||
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):
|
||||
"""Test catalog representation."""
|
||||
self.assertIn('TestCatalog', repr(self.catalog))
|
||||
|
|
Loading…
Reference in New Issue
Block a user