Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add start_session method for client
  • Loading branch information
assigdev committed Oct 4, 2018
commit 9e4ad7389f1d5f1b6fbc09d28b286902f8ed1923
13 changes: 12 additions & 1 deletion pytest_async_mongodb/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def pytest_addoption(parser):
help='Try loading fixtures from this directory')



def wrapper(func):
@functools.wraps(func)
async def wrapped(*args, **kwargs):
Expand All @@ -51,6 +50,14 @@ def __getattribute__(self, name):
return attr


class Session:
async def __aenter__(self):
await asyncio.sleep(0)

async def __aexit__(self, exc_type, exc, tb):
await asyncio.sleep(0)


class AsyncCollection(AsyncClassMethod, mongomock.Collection):

ASYNC_METHODS = [
Expand All @@ -74,6 +81,10 @@ async def find_one(self, filter=None, *args, **kwargs):
except StopIteration:
return None

async def start_session(self, **kwargs):
await asyncio.sleep(0)
return Session()


class AsyncDatabase(AsyncClassMethod, mongomock.Database):

Expand Down