Opened 9 years ago
Last modified 9 years ago
#26270 closed Bug
testing framework requires database configuration from lean databaseless project — at Initial Version
Reported by: | Herbert | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 1.9 |
Severity: | Normal | Keywords: | database |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Create django project and application and remove some superfluous files:
django-admin startproject foo cd foo/ django-admin startapp bar rm -rf bar/migrations/ bar/models.py bar/apps.py bar/admin.py foo/wsgi.py
Changed the files to look like this:
# foo/settings.py import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = '1234' DEBUG = True ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'bar' ] MIDDLEWARE_CLASSES = [] ROOT_URLCONF = 'foo.urls' DATABASES = {}
# foo/urls.py from django.conf.urls import url from bar.views import my_oh_my urlpatterns = [ url(r'^$', my_oh_my), ]
# bar/tests.py from django.test import TestCase class TestFoo(TestCase): def test_foo(self): assert True print('tested!')
# bar/views.py from django.shortcuts import render from django.http.response import HttpResponse def my_oh_my(request): return HttpResponse('my, oh, my!')
Both foo and bar have an empty __init__.py
. Running this project as a server is fine, however testing it results in this error:
# python3 manage.py test tested! .E ====================================================================== ERROR: test_foo (bar.tests.TestFoo) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/herbert/.local/lib/python3.4/site-packages/django/test/testcases.py", line 217, in __call__ self._post_teardown() File "/home/herbert/.local/lib/python3.4/site-packages/django/test/testcases.py", line 919, in _post_teardown self._fixture_teardown() File "/home/herbert/.local/lib/python3.4/site-packages/django/test/testcases.py", line 1072, in _fixture_teardown return super(TestCase, self)._fixture_teardown() File "/home/herbert/.local/lib/python3.4/site-packages/django/test/testcases.py", line 955, in _fixture_teardown inhibit_post_migrate=inhibit_post_migrate) File "/home/herbert/.local/lib/python3.4/site-packages/django/core/management/__init__.py", line 119, in call_command return command.execute(*args, **defaults) File "/home/herbert/.local/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/home/herbert/.local/lib/python3.4/site-packages/django/core/management/commands/flush.py", line 49, in handle allow_cascade=allow_cascade) File "/home/herbert/.local/lib/python3.4/site-packages/django/core/management/sql.py", line 15, in sql_flush tables = connection.introspection.django_table_names(only_existing=True, include_views=False) File "/home/herbert/.local/lib/python3.4/site-packages/django/db/backends/base/introspection.py", line 86, in django_table_names existing_tables = self.table_names(include_views=include_views) File "/home/herbert/.local/lib/python3.4/site-packages/django/db/backends/base/introspection.py", line 56, in table_names with self.connection.cursor() as cursor: File "/home/herbert/.local/lib/python3.4/site-packages/django/db/backends/base/base.py", line 233, in cursor cursor = self.make_cursor(self._cursor()) File "/home/herbert/.local/lib/python3.4/site-packages/django/db/backends/dummy/base.py", line 21, in complain raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. ---------------------------------------------------------------------- Ran 1 test in 0.002s FAILED (errors=1)
It states that I need to better configure the DATABASES variable, which I think is not adequate.
(django.version == '1.9.2')
Note:
See TracTickets
for help on using tickets.
project files