Skip to content

Commit

Permalink
feat: Add flag to clean up postgres databases.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Mar 7, 2024
1 parent 978190f commit eeef1ec
Show file tree
Hide file tree
Showing 14 changed files with 827 additions and 347 deletions.
529 changes: 273 additions & 256 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-mock-resources"
version = "2.10.1"
version = "2.11.0"
description = "A pytest plugin for easily instantiating reproducible mock resources."
authors = [
"Omar Khan <oakhan3@gmail.com>",
Expand Down Expand Up @@ -54,11 +54,12 @@ filelock = {version = "*", optional = true}
python-on-whales = {version = ">=0.22.0", optional = true}

[tool.poetry.dev-dependencies]
botocore = ">=1.31.63"
botocore = "1.31.63"
coverage = "*"
moto = ">=2.3.2"
mypy = {version = "0.982"}
pytest-asyncio = "*"
pytest-order = "^1.2.0"
pytest-xdist = "*"
responses = ">=0.23.0"
ruff = "0.1.15"
Expand Down Expand Up @@ -145,6 +146,7 @@ filterwarnings = [
"ignore:stream argument is deprecated. Use stream parameter in request directly:DeprecationWarning",
"ignore:Boto3 will no longer support Python 3.7.*::boto3",
"ignore:datetime.datetime.utcnow.*:DeprecationWarning",
"ignore:unclosed.*:ResourceWarning",
]

[build-system]
Expand Down
6 changes: 4 additions & 2 deletions src/pytest_mock_resources/fixture/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import uuid
from typing import Union

Expand All @@ -12,14 +14,14 @@ def generate_fixture_id(enabled: bool = True, name=""):
return None


def asyncio_fixture(async_fixture, scope="function"):
def asyncio_fixture(async_fixture, scope: Scope = "function", name=None):
# pytest-asyncio in versions >=0.17 force you to use a `pytest_asyncio.fixture`
# call instead of `pytest.fixture`. Given that this would introduce an unnecessary
# dependency on pytest-asyncio (when there are other alternatives) seems less than
# ideal, so instead we can just set the flag that they set, as the indicator.
async_fixture._force_asyncio_fixture = True

fixture = pytest.fixture(scope=scope)
fixture = pytest.fixture(scope=scope, name=name)
return fixture(async_fixture)


Expand Down
Loading

0 comments on commit eeef1ec

Please sign in to comment.