mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 02:53:56 +03:00
28 lines
642 B
Python
28 lines
642 B
Python
|
"""ProvidedInstance provider traversal tests."""
|
||
|
|
||
|
from dependency_injector import providers
|
||
|
|
||
|
|
||
|
def test_traverse():
|
||
|
provider1 = providers.Provider()
|
||
|
provider = provider1.provided
|
||
|
|
||
|
all_providers = list(provider.traverse())
|
||
|
|
||
|
assert len(all_providers) == 1
|
||
|
assert provider1 in all_providers
|
||
|
|
||
|
|
||
|
def test_traverse_overridden():
|
||
|
provider1 = providers.Provider()
|
||
|
provider2 = providers.Provider()
|
||
|
|
||
|
provider = provider1.provided
|
||
|
provider.override(provider2)
|
||
|
|
||
|
all_providers = list(provider.traverse())
|
||
|
|
||
|
assert len(all_providers) == 2
|
||
|
assert provider1 in all_providers
|
||
|
assert provider2 in all_providers
|