-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: empty async context object #59
- Loading branch information
1 parent
d9dda3e
commit a1cf18b
Showing
3 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class AsyncContext: | ||
"""An object appropriate to fake async context manager.""" | ||
|
||
async def __aenter__(self): | ||
... | ||
|
||
async def __aexit__(self, exc_type, exc_value, traceback): | ||
... |
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,8 +1,9 @@ | ||
"""Fake objects designed with OOP in mind.""" | ||
from _primitives.argument import Argument | ||
from _primitives.async_context import AsyncContext | ||
from _primitives.awaitable import Awaitable | ||
from _primitives.callable import Callable | ||
from _primitives.instance import Instance | ||
|
||
|
||
__all__ = ["Argument", "Awaitable", "Callable", "Instance"] | ||
__all__ = ["Argument", "Awaitable", "Callable", "Instance", "AsyncContext"] |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Tests related to `primitives.AsyncContext` object.""" | ||
import pytest | ||
|
||
from primitives import AsyncContext | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_async_context_object_return_null(): | ||
"""Empty `AsyncContext` object should return null. | ||
An async context object is empty when return value was not specified. | ||
""" | ||
async_context = AsyncContext() | ||
async with async_context as result: | ||
assert result is None |