-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed dynamic container and its documentation. Added safeguards. (#152
- Loading branch information
1 parent
1cb1087
commit 884653f
Showing
4 changed files
with
24 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests import container | ||
from that_depends import BaseContainer, providers | ||
|
||
|
||
class DIContainer(BaseContainer): | ||
sync_resource: providers.Resource[datetime.datetime] | ||
async_resource: providers.Resource[datetime.datetime] | ||
|
||
|
||
DIContainer.sync_resource = providers.Resource(container.create_sync_resource) | ||
DIContainer.async_resource = providers.Resource(container.create_async_resource) | ||
|
||
|
||
async def test_dynamic_container() -> None: | ||
sync_resource = await DIContainer.sync_resource() | ||
async_resource = await DIContainer.async_resource() | ||
|
||
assert isinstance(sync_resource, datetime.datetime) | ||
assert isinstance(async_resource, datetime.datetime) | ||
async def test_dynamic_container_not_supported() -> None: | ||
new_provider = providers.Resource(container.create_sync_resource) | ||
with pytest.raises(AttributeError): | ||
DIContainer.sync_resource = new_provider | ||
|
||
await DIContainer.tear_down() | ||
with pytest.raises(AttributeError): | ||
DIContainer.something_new = new_provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters