Skip to content

Pytest run fails due to db query at import time #80

@IBA20

Description

@IBA20

The below code in conf.py queries database at import time:

def get_fixed_settings() -> Dict[str, bool]:
    """Return fixed settings."""
    is_postgresql = connection.vendor == 'postgresql'
    has_trigram_extension = False
    if is_postgresql:
        with connection.cursor() as cursor:
            cursor.execute("SELECT COUNT(*) FROM pg_available_extensions WHERE name='pg_trgm'")

For this reason pytest run fails with error:
RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.

Any ideas what to do with this?

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