Closed guyjacks closed 4 years ago
I have the same issue, Any suggestion? @guyjacks
Update: Fixed
Info:
pytest==3.7.2
pytest-django==3.4.2
Python 3.6.0
cmd:
$ pytest -s
Traceback:
========================================================================================================== ERRORS ==========================================================================================================
__________________________________________________________________________________ ERROR at setup of TestUserRegister.test_user_register ___________________________________________________________________________________
self = <django.db.backends.utils.CursorWrapper object at 0x7f6e7ee1a240>
sql = 'ALTER TABLE "allauth_socialapp_sites" ADD CONSTRAINT "allauth_socialapp_sites_site_id_26af3e5b_fk_django_site_id" FOREIGN KEY ("site_id") REFERENCES "django_site" ("id") DEFERRABLE INITIALLY DEFERRED', params = ()
ignored_wrapper_args = (False, {'connection': <django.db.backends.postgresql.base.DatabaseWrapper object at 0x7f6e83b89390>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f6e7ee1a240>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
return self.cursor.execute(sql)
else:
> return self.cursor.execute(sql, params)
E psycopg2.ProgrammingError: relation "django_site" does not exist
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/utils.py:85: ProgrammingError
The above exception was the direct cause of the following exception:
request = <SubRequest '_django_db_marker' for <Function 'test_user_register'>>
@pytest.fixture(autouse=True)
def _django_db_marker(request):
"""Implement the django_db marker, internal to pytest-django.
This will dynamically request the ``db``, ``transactional_db`` or
``django_db_reset_sequences`` fixtures as required by the django_db marker.
"""
marker = request.node.get_closest_marker('django_db')
if marker:
transaction, reset_sequences = validate_django_db(marker)
if reset_sequences:
request.getfixturevalue('django_db_reset_sequences')
elif transaction:
request.getfixturevalue('transactional_db')
else:
> request.getfixturevalue('db')
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/pytest_django/plugin.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/pytest_django/fixtures.py:98: in django_db_setup
**setup_databases_args
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/test/utils.py:176: in setup_databases
serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/base/creation.py:68: in create_test_db
run_syncdb=True,
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/core/management/__init__.py:141: in call_command
return command.execute(*args, **defaults)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/core/management/base.py:335: in execute
output = self.handle(*args, **options)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/core/management/commands/migrate.py:169: in handle
self.sync_apps(connection, executor.loader.unmigrated_apps)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/core/management/commands/migrate.py:307: in sync_apps
self.stdout.write(" Running deferred SQL...\n")
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/base/schema.py:90: in __exit__
self.execute(sql)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/base/schema.py:117: in execute
cursor.execute(sql, params)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/raven/contrib/django/client.py:123: in execute
return real_execute(self, sql, params)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/utils.py:68: in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/utils.py:77: in _execute_with_wrappers
return executor(sql, params, many, context)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/utils.py:85: in _execute
return self.cursor.execute(sql, params)
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/utils.py:89: in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.db.backends.utils.CursorWrapper object at 0x7f6e7ee1a240>
sql = 'ALTER TABLE "allauth_socialapp_sites" ADD CONSTRAINT "allauth_socialapp_sites_site_id_26af3e5b_fk_django_site_id" FOREIGN KEY ("site_id") REFERENCES "django_site" ("id") DEFERRABLE INITIALLY DEFERRED', params = ()
ignored_wrapper_args = (False, {'connection': <django.db.backends.postgresql.base.DatabaseWrapper object at 0x7f6e83b89390>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f6e7ee1a240>})
def _execute(self, sql, params, *ignored_wrapper_args):
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
if params is None:
return self.cursor.execute(sql)
else:
> return self.cursor.execute(sql, params)
E django.db.utils.ProgrammingError: relation "django_site" does not exist
/home/or/.pyenv/versions/3.6.0/envs/env3.6.0/lib/python3.6/site-packages/django/db/backends/utils.py:85: ProgrammingError
This seems unlikely to be caused by pytest-django, and a possible cause was given above, so I'll close this. Let us know if this still happens.
The test runner is failing during database setup as you can see in the error output below.
Error output: https://gist.github.com/5da65945471268e1828df6d95adeff83 Base Settings: https://gist.github.com/7b640c2830ab23439ad8425f9f76167c Test Settings: https://gist.github.com/d2f65311d9a1b2f7bd13526205df9b11
The actual test being run: https://gist.github.com/19b5c140b051bee30bea1945e6a89f8f
I can successfully run pytest to test other parts of the app, but I cannot get it to work with the database.