pytest-dev / pytest-dev/pytest-django

Spatialite backed test databases are not allowed to be :memory: based

Open
#477 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug db-configuration
Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

On my test settings I have this DATABASES config:

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.spatialite',
        'NAME': ':memory:',
    }
}

As I'm not using exactly sqlite as engine, pytest-django renames my DB by preppending test_, while I want to use ":memory:". This causes the tear-down to fail, as sqlite/spatialite wants to delete the db file.

I managed to go around this issue by overriding the django_db_modify_db_settings_xdist_suffix fixture to allow using :memory: for spatialite.

Having said that... I'm not 100% sure I can use :memory: with spatialite.

Django==1.10
pytest==3.0.3
pytest-django==3.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at pytest_django/fixtures.py around line 35 and the django_db_modify_db_settings_xdist_suffix fixture, then reproduce teardown with the shown Spatialite :memory: configuration. Confirm whether :memory: is supported and consider the work complete when the configuration no longer triggers the database rename or deletion failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python, sqlite
Domain
database, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.