mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Add tests for injections
This commit is contained in:
parent
3bb9146496
commit
93c8bd6438
|
@ -30,6 +30,28 @@ class PositionalInjectionTests(unittest.TestCase):
|
||||||
injection = providers.PositionalInjection(provider)
|
injection = providers.PositionalInjection(provider)
|
||||||
self.assertIs(injection.get_original_value(), provider)
|
self.assertIs(injection.get_original_value(), provider)
|
||||||
|
|
||||||
|
def test_deepcopy(self):
|
||||||
|
provider = providers.Factory(object)
|
||||||
|
injection = providers.PositionalInjection(provider)
|
||||||
|
|
||||||
|
injection_copy = providers.deepcopy(injection)
|
||||||
|
|
||||||
|
self.assertIsNot(injection_copy, injection)
|
||||||
|
self.assertIsNot(injection_copy.get_original_value(),
|
||||||
|
injection.get_original_value())
|
||||||
|
|
||||||
|
def test_deepcopy_memo(self):
|
||||||
|
provider = providers.Factory(object)
|
||||||
|
injection = providers.PositionalInjection(provider)
|
||||||
|
injection_copy_orig = providers.PositionalInjection(provider)
|
||||||
|
|
||||||
|
injection_copy = providers.deepcopy(
|
||||||
|
injection, {id(injection): injection_copy_orig})
|
||||||
|
|
||||||
|
self.assertIs(injection_copy, injection_copy_orig)
|
||||||
|
self.assertIs(injection_copy.get_original_value(),
|
||||||
|
injection.get_original_value())
|
||||||
|
|
||||||
|
|
||||||
class NamedInjectionTests(unittest.TestCase):
|
class NamedInjectionTests(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -60,3 +82,25 @@ class NamedInjectionTests(unittest.TestCase):
|
||||||
provider = providers.Factory(object)
|
provider = providers.Factory(object)
|
||||||
injection = providers.NamedInjection('name', provider)
|
injection = providers.NamedInjection('name', provider)
|
||||||
self.assertIs(injection.get_original_value(), provider)
|
self.assertIs(injection.get_original_value(), provider)
|
||||||
|
|
||||||
|
def test_deepcopy(self):
|
||||||
|
provider = providers.Factory(object)
|
||||||
|
injection = providers.NamedInjection('name', provider)
|
||||||
|
|
||||||
|
injection_copy = providers.deepcopy(injection)
|
||||||
|
|
||||||
|
self.assertIsNot(injection_copy, injection)
|
||||||
|
self.assertIsNot(injection_copy.get_original_value(),
|
||||||
|
injection.get_original_value())
|
||||||
|
|
||||||
|
def test_deepcopy_memo(self):
|
||||||
|
provider = providers.Factory(object)
|
||||||
|
injection = providers.NamedInjection('name', provider)
|
||||||
|
injection_copy_orig = providers.NamedInjection('name', provider)
|
||||||
|
|
||||||
|
injection_copy = providers.deepcopy(
|
||||||
|
injection, {id(injection): injection_copy_orig})
|
||||||
|
|
||||||
|
self.assertIs(injection_copy, injection_copy_orig)
|
||||||
|
self.assertIs(injection_copy.get_original_value(),
|
||||||
|
injection.get_original_value())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user