schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
183 stars 19 forks source link

create_postgres_fixture fails on 2.11.0 #207

Closed seanmurphyuq closed 6 months ago

seanmurphyuq commented 7 months ago

Describe the bug <2.10.2 works fine, but due to a change introduced here in 2.11.0, a create_postgres_fixture call fails with "'pdb' is not a package", at least on Python 3.11.9

Environment

To Reproduce Steps to reproduce the behavior:

from pytest_mock_resources import create_postgres_fixture
alembic_engine = create_postgres_fixture()

Expected behavior Don't raise an exception

Actual Behavior

Traceback (most recent call last):
  File "/REDACTED/tests/conftest.py", line 9, in <module>
    alembic_engine = create_postgres_fixture()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/REDACTED/python3.11/site-packages/pytest_mock_resources/fixture/postgresql.py", line 115, in create_postgres_fixture
    register_scope_fixture(
  File "/REDACTED/python3.11/site-packages/pytest_mock_resources/fixture/postgresql.py", line 178, in register_scope_fixture
    caller_globals = find_caller_globals()
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/REDACTED/python3.11/site-packages/pytest_mock_resources/fixture/postgresql.py", line 485, in find_caller_globals
    str(importlib.resources.files("pdb")),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/resources/_common.py", line 22, in files
    return from_package(get_package(package))
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/resources/_common.py", line 55, in get_package
    raise TypeError(f\'{package!r} is not a package\')
TypeError: \'pdb\' is not a package
Traceback (most recent call last):
  File "/REDACTED/tests/conftest.py", line 9, in <module>
    alembic_engine = create_postgres_fixture()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/REDACTED/python3.11/site-packages/pytest_mock_resources/fixture/postgresql.py", line 115, in create_postgres_fixture
    register_scope_fixture(
  File "/REDACTED/python3.11/site-packages/pytest_mock_resources/fixture/postgresql.py", line 178, in register_scope_fixture
    caller_globals = find_caller_globals()
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/REDACTED/python3.11/site-packages/pytest_mock_resources/fixture/postgresql.py", line 485, in find_caller_globals
    str(importlib.resources.files("pdb")),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/resources/_common.py", line 22, in files
    return from_package(get_package(package))
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/resources/_common.py", line 55, in get_package
    raise TypeError(f\'{package!r} is not a package\')
TypeError: \'pdb\' is not a package

Minimal repro:

import importlib.resources

importlib.resources.files("pytest_mock_resources") #passes
importlib.resources.files("pdb") #fails
DanCardin commented 7 months ago

I yanked v2.11.0 almost immediately after pushing it, i hope you just got unlucky timing and it's not a tooling issue ignoring the yank?

seanmurphyuq commented 7 months ago

Ah yeah guessing our internal package repo cloned it before it got yanked...