Skip to content

Commit

Permalink
fix CI failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Mar 7, 2024
1 parent 48c03c2 commit f4aa625
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/pytest_mock_resources/compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import importlib.resources
import sys

from pytest_mock_resources.compat.import_ import ImportAdaptor

# isort: split
Expand Down Expand Up @@ -70,6 +73,13 @@
pymysql = ImportAdaptor("pymysql", "mysql")


def get_resource(package: str) -> str:
if sys.version_info >= (3, 9):
return str(importlib.resources.files(package))

return str(importlib.resources.path(package, "").__enter__())


__all__ = [
"sqlalchemy",
"psycopg2",
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_mock_resources/container/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from python_on_whales.docker_client import DockerClient


DEFAULT_RETRIES = 40
DEFAULT_RETRIES = 60
DEFAULT_INTERVAL = 0.5


Expand Down
9 changes: 3 additions & 6 deletions src/pytest_mock_resources/fixture/postgresql.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import importlib.resources
import inspect
import logging
from typing import cast
Expand All @@ -8,6 +7,7 @@
from sqlalchemy import text
from sqlalchemy.engine import Connection, Engine

from pytest_mock_resources.compat import get_resource
from pytest_mock_resources.container.base import (
async_retry,
DEFAULT_RETRIES,
Expand Down Expand Up @@ -480,13 +480,10 @@ def _sync_drop_database(conn: Connection, database_name: str):


def find_caller_globals():
ignore_paths = (
str(importlib.resources.files("pytest_mock_resources")),
str(importlib.resources.files("pdb")),
)
ignore_path = get_resource("pytest_mock_resources")
stack = inspect.stack()
for item in stack:
if item.filename.startswith(ignore_paths):
if item.filename.startswith(ignore_path) or item.filename.endswith("pdb.py"):
continue

frame = item.frame
Expand Down

0 comments on commit f4aa625

Please sign in to comment.