Skip to content

Commit

Permalink
feat: Add async support (postgres)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbukachi authored and DanCardin committed Jun 28, 2021
1 parent 26eabc2 commit f45b078
Show file tree
Hide file tree
Showing 15 changed files with 675 additions and 250 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ def test_view_function_user_with_purchases(pg):
from pytest_mock_resources import create_mysql_fixture
```

## Async
It's also possible to create and use async engines (postgres only, sqlalchemy >= 1.4, python >= 3.6):
```python
import pytest
from sqlalchemy import text
from pytest_mock_resources import create_postgres_fixture

postgres_async = create_postgres_fixture(async_=True)

@pytest.mark.asyncio # pytest-asyncio needs to be installed
async def test_basic_postgres_fixture_async(postgres_async):
async with postgres_async.connect() as conn:
await conn.execute(text("select 1"))
```
## Installing

```bash
Expand All @@ -119,6 +133,8 @@ pip install "pytest-mock-resources"
# For postgres install EITHER of the following:
pip install "pytest-mock-resources[postgres-binary]"
pip install "pytest-mock-resources[postgres]"
# For postgres async
pip install "pytest-mock-resources[postgres-async]"

# For redshift install EITHER of the following:
# (redshift fixtures require postgres dependencies...)
Expand Down
Loading

0 comments on commit f45b078

Please sign in to comment.