Skip to content

Live server error with sqlite3 #783

Open
@cleder

Description

@cleder

When using the live_server in an integration test fixture:

@pytest.fixture(scope='session', name='server_url')
def get_server_url(live_server, environment):
    """Start a django server to test against and return the url of the server."""
    yield live_server.url

the following error is generated:


self = <[AttributeError("'LiveServer' object has no attribute 'thread'") raised in repr()] LiveServer object at 0x80526a8d0>
addr = 'localhost'

    def __init__(self, addr):
        import django
        from django.db import connections
        from django.test.testcases import LiveServerThread
        from django.test.utils import modify_settings
    
        connections_override = {}
        for conn in connections.all():
            # If using in-memory sqlite databases, pass the connections to
            # the server thread.
            if (
                conn.settings_dict["ENGINE"] == "django.db.backends.sqlite3"
                and conn.settings_dict["NAME"] == ":memory:"
            ):
                # Explicitly enable thread-shareability for this connection
>               conn.allow_thread_sharing = True
E               AttributeError: can't set attribute

/home/goldeneagle/venv/lib/python3.7/site-packages/pytest_django/live_server_helper.py:27: AttributeError

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