Skip to content

Running test_model_definitions_match_ddl() via imports will not show the context #79

@jankatins

Description

@jankatins

I run a normal pytest invocation and only import the tests I want:

test_migration.py

from pytest_alembic.tests import test_model_definitions_match_ddl  # noqa
PYTHON_TEST_DIRS := tests/

.PHONY: test
test:  ## Runs all tests.
	# Use high verbosity to see the diffs
	poetry run python -m pytest -vv $(PYTHON_TEST_DIRS)

the tests work, but sometimes I have (random?) failures, but it doesn't show what is actually the problem:

>               raise AlembicTestFailure(
                    "The models describing the DDL of your database are out of sync with the set of "
                    "steps described in the revision history. This usually means that someone has "
                    "made manual changes to the database's DDL, or some model has been changed "
                    "without also generating a migration to describe that change.",
                    context=[
                        (
                            "The upgrade which would have been generated would look like",
                            rendered_upgrade,
                        )
                    ],
                )
E               pytest_alembic.plugin.error.AlembicTestFailure: The models describing the DDL of your database are out of sync with the set of steps described in the revision history. This usually means that someone has made manual changes to the database's DDL, or some model has been changed without also generating a migration to describe that change.

Unfortunately, it doesn't show me what is problematic, as the context is not rendered/printed by pytest.

(funnily, after adding the rendered stuff to the message via + rendered_upgrade, the test passed in the next run, so something is definitely off in my setup resulting in flaky tests, but this prevents me from seeing that problem)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions