Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 9d129b1

Browse files
committed
Incorporate fixture from pytest-dynamodb branch
1 parent 0e41e5b commit 9d129b1

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ dynamic = [ "version" ]
2626
[project.optional-dependencies]
2727
test = [
2828
"pytest",
29-
"pytest-dynamodb @ git+https://github.com/lpsinger/pytest-dynamodb@aioboto3",
29+
"pytest-asyncio",
30+
"pytest-dynamodb",
3031
]
3132

3233
[project.urls]

test_dynamodb_autoincrement.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,37 @@
22
# Administrator of the National Aeronautics and Space Administration.
33
# All Rights Reserved.
44

5-
from botocore.exceptions import ClientError
65
import asyncio
6+
7+
import aioboto3
78
import pytest
9+
from botocore.exceptions import ClientError
10+
from pytest import FixtureRequest
811
from pytest_asyncio import fixture as asyncio_fixture
12+
from pytest_dynamodb.factories import get_config
913

1014
from dynamodb_autoincrement import DynamoDBAutoIncrement, DynamoDBHistoryAutoIncrement
1115

12-
1316
N = 20
1417

1518

19+
@asyncio_fixture
20+
async def asyncio_dynamodb(request: FixtureRequest, dynamodb):
21+
proc_fixture = request.getfixturevalue("dynamodb_proc")
22+
config = get_config(request)
23+
24+
session = aioboto3.Session(
25+
aws_access_key_id=config["aws_access_key"],
26+
aws_secret_access_key=config["aws_secret_key"],
27+
region_name=config["aws_region"],
28+
)
29+
30+
async with session.resource(
31+
"dynamodb", endpoint_url=f"http://{proc_fixture.host}:{proc_fixture.port}"
32+
) as dynamo_db:
33+
yield dynamo_db
34+
35+
1636
@asyncio_fixture
1737
async def create_tables(asyncio_dynamodb):
1838
await asyncio.gather(

0 commit comments

Comments
 (0)