Skip to content

Commit

Permalink
feat: empty async context object #59
Browse files Browse the repository at this point in the history
  • Loading branch information
proofit404 committed Aug 24, 2021
1 parent d9dda3e commit a1cf18b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/_primitives/async_context.py
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):
...
3 changes: 2 additions & 1 deletion src/primitives/__init__.py
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"]
16 changes: 16 additions & 0 deletions tests/test_async_context.py
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

0 comments on commit a1cf18b

Please sign in to comment.