Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest --test-alembic command fails with pytest 8.1.0 #100

Closed
Topech opened this issue Mar 4, 2024 · 4 comments · Fixed by #101
Closed

pytest --test-alembic command fails with pytest 8.1.0 #100

Topech opened this issue Mar 4, 2024 · 4 comments · Fixed by #101

Comments

@Topech
Copy link

Topech commented Mar 4, 2024

when I run pytest --test-alembic or pytest -m 'alembic' on pytest==8.1.0 I get the following error.

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 282, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 138, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/logging.py", line 785, in pytest_sessionstart
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pytest_alembic/plugin/hooks.py", line 72, in pytest_sessionstart
INTERNALERROR>     session.config.pluginmanager.register(plugin, "pytest-alembic")
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 497, in register
INTERNALERROR>     plugin_name = super().register(plugin, name)
INTERNALERROR>                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 167, in register
INTERNALERROR>     self._verify_hook(hook, hookimpl)
INTERNALERROR>   File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 342, in _verify_hook
INTERNALERROR>     raise PluginValidationError(
INTERNALERROR> pluggy._manager.PluginValidationError: Plugin 'pytest-alembic' for hook 'pytest_collect_file'
INTERNALERROR> hookimpl definition: pytest_collect_file(file_path, path, parent)
INTERNALERROR> Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec

If I change back to pytest version 8.0.2, the tests work as expected.


pytest version: 8.1.0
pytest-alembic version: 0.10.7

my tests/conftest.py:

import pytest
from sqlalchemy import MetaData, create_engine


@pytest.fixture
def alembic_engine():
    POSTGRES_USER = "postgres"
    POSTGRES_PASSWORD = "password"
    POSTGRES_SERVER = "test-db"
    POSTGRES_DB = "app"
    SQLALCHEMY_DATABASE_URI = (
        f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_SERVER}/{POSTGRES_DB}"
    )
    engine = create_engine(
        SQLALCHEMY_DATABASE_URI, pool_pre_ping=True, pool_size=30, max_overflow=40
    )

    if "test-db" in engine.url:
        m = MetaData()
        m.reflect(engine)
        m.drop_all(engine)

    return engine

@Topech
Copy link
Author

Topech commented Mar 4, 2024

Apologies, forgot to mention that this is on a M1 macbook pro, within an ARM python:3.11 docker image.

python version 3.11.8

@kain88-de
Copy link

I experience the same on Ubuntu 23.10. I think this is independent of the OS.

@DanCardin
Copy link
Contributor

DanCardin commented Mar 4, 2024

pytest-dev/pytest#12069 Seems like they accidentally didn't report a bunch of deprecations, and there seems to be no blessed way to support multiple versions of pytest without just version-defining the different shapes, given the way that they've done this migration. alas

I think it ought to be fixed in v0.11.0

@Topech
Copy link
Author

Topech commented Mar 5, 2024

Perfect thanks for the fix. Looks like pytest just yanked 8.1.0 back down to 8.0.2 in that issue you mentioned earlier, but everything seems to be working fine even after that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants