question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Always asks about deleting an SQLite database file specified in TEST_NAME

See original GitHub issue

When specifying an on-disk SQLite database in the TEST_NAME database setting, django-nose always asks if the user wants to try deleting it, even if there was no such file.

To reproduce, install django-nose 7fd0132090256e752119f90a3d4568203c486f2e and create a new Django project with django-admin.py startproject. Do these changes to settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/tmp/db.sqlite',
        'TEST_NAME': '/tmp/test.sqlite'
    }
}

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

INSTALLED_APPS = (
    # ...
    'django_nose',
    # ...
}

Run the tests:

$ rm -f /tmp/db.sqlite /tmp/test.sqlite
$ ./manage.py test
nosetests --verbosity=1
Creating test database for alias 'default'...
Destroying old test database 'default'...
Type 'yes' if you would like to try deleting the test database '/tmp/test.sqlite', or 'no' to cancel: yes

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

The reason for this behavior seems to be in django_nose.runner._should_create_database(). The connection.cursor() line creates a zero-length SQLite file, and later django.db.backends.sqlite3.creation.DatabaseCreation._create_test_db() finds it and suggests deleting it.

If TEST_NAME is not specified and Django’s default mechanism for generating the test database name is used, everything works as expected.

Issue Analytics

  • State:open
  • Created 11 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
steragocommented, Jul 30, 2014

This issue is still present in django_nose 1.2. A workaround for me is using --noinput as option for the manage.py test command.

0reactions
kellycampbellcommented, Jan 11, 2017

I’m running into this using Django 1.10.5 and django-nose 1.4.4.

I’ve traced it down to runner.py in _should_create_database(connection) where it does “connection.cursor()”. The sqlite file doesn’t exist before that call and does afterwards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Always asks about deleting an SQLite database file ... - GitHub
When specifying an on-disk SQLite database in the TEST_NAME database setting, django-nose always asks if the user wants to try deleting it, ...
Read more >
c# 4.0 - Delete sqlite db file - Stack Overflow
I am developing a C# application with its backend as sqlite. In my application I have a button for cleaning the database (deleting...
Read more >
when database's all table get deleted - SQLite Forum
I have use sqlite database in my application. in my application without deleting the database's table. all table get deleted.
Read more >
django-admin and manage.py
If you need to switch between multiple Django settings files, ... Runs the command-line client for the database engine specified in your ENGINE...
Read more >
sqflite | Flutter Package - Pub.dev
Flutter plugin for SQLite, a self-contained, high-reliability, embedded, ... A SQLite database is a file in the file system identified by a path....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found