Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REUSE_DB=1 fails intermittantly on Django 1.8+ #229

Open
jwhitlock opened this issue Aug 5, 2015 · 3 comments
Open

REUSE_DB=1 fails intermittantly on Django 1.8+ #229

jwhitlock opened this issue Aug 5, 2015 · 3 comments
Labels

Comments

@jwhitlock
Copy link
Contributor

The runtests.sh tests fail intermittently on Django 1.8+, and possibly other versions. The traceback looks like this:

======================================================================
ERROR: Test that votes is initialized to 0.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: testapp_question

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/john/src/django-nose/testapp/tests.py", line 31, in test_question
    question_text="What is your quest?", pub_date=datetime(1975, 4, 9))
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/manager.py", line 122, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/query.py", line 401, in create
    obj.save(force_insert=True, using=self.db)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/base.py", line 679, in save
    force_update=force_update, update_fields=update_fields)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/base.py", line 707, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/base.py", line 791, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/base.py", line 830, in _do_insert
    using=using, raw=raw)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/manager.py", line 122, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/query.py", line 1033, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 980, in execute_sql
    cursor.execute(sql, params)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/john/src/django-nose/.tox/py34-django-master/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: testapp_question

This suggests that REUSE_DB=1 is detecting that it does not have to recreate the database when it needs to. Sometimes the issue goes away on re-running, and sometimes it does not.

@jwhitlock jwhitlock added the bug label Aug 5, 2015
@jwhitlock jwhitlock added this to the Fix REUSE_DB=1 milestone Aug 5, 2015
@jgoettsch
Copy link

I have a similar issue with Django 1.7:

OperationalError: FATAL: database "test_foo" does not exist

@tarkatronic
Copy link

Are you using multiple databases in your application? If so, this may be a result of #255. This is exactly what I was seeing, both with and without REUSE_DB=1.

@owais
Copy link

owais commented May 11, 2017

You could be facing #76. There is a bug that uses the real database in tests in some cases instead of the test DB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants