mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-27 12:04:00 +03:00
32 lines
773 B
Python
32 lines
773 B
Python
|
"""AttributeGetter provider traversal tests."""
|
||
|
|
||
|
from dependency_injector import providers
|
||
|
|
||
|
|
||
|
def test_traverse():
|
||
|
provider1 = providers.Provider()
|
||
|
provided = provider1.provided
|
||
|
provider = provided.attr
|
||
|
|
||
|
all_providers = list(provider.traverse())
|
||
|
|
||
|
assert len(all_providers) == 2
|
||
|
assert provider1 in all_providers
|
||
|
assert provided in all_providers
|
||
|
|
||
|
|
||
|
def test_traverse_overridden():
|
||
|
provider1 = providers.Provider()
|
||
|
provided = provider1.provided
|
||
|
provider2 = providers.Provider()
|
||
|
|
||
|
provider = provided.attr
|
||
|
provider.override(provider2)
|
||
|
|
||
|
all_providers = list(provider.traverse())
|
||
|
|
||
|
assert len(all_providers) == 3
|
||
|
assert provider1 in all_providers
|
||
|
assert provider2 in all_providers
|
||
|
assert provided in all_providers
|