Opened 15 years ago
Closed 15 years ago
#11942 closed (wontfix)
testing from a checkout is overly complicated
Reported by: | termie | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I expect this is a rather common progression for anybody who finds some random line of code they'd like to patch and want to run tests.
Some steps towards this are in ticket 6298
termie@termie:~/p/django % svn info 15:48:00 Path: . URL: http://code.djangoproject.com/svn/django/trunk Repository Root: http://code.djangoproject.com/svn Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37 Revision: 11434 Node Kind: directory Schedule: normal Last Changed Author: kmtracey Last Changed Rev: 11423 Last Changed Date: 2009-08-09 08:44:09 -0700 (Sun, 09 Aug 2009) termie@termie:~/p/django % svn up 15:48:03 U django/db/models/sql/expressions.py U django/db/backends/oracle/base.py U django/db/backends/oracle/introspection.py U django/db/backends/__init__.py U django/conf/locale/he/LC_MESSAGES/django.po U django/conf/locale/he/LC_MESSAGES/django.mo U django/forms/fields.py U django/forms/forms.py U django/forms/widgets.py U django/core/handlers/modpython.py U django/core/management/base.py U django/core/management/commands/inspectdb.py U django/core/management/__init__.py U django/core/urlresolvers.py U django/views/decorators/cache.py U django/utils/datastructures.py U django/utils/decorators.py U django/contrib/gis/shortcuts.py U django/contrib/gis/db/models/sql/aggregates.py U django/contrib/gis/tests/geoapp/test_regress.py U django/contrib/gis/management/commands/inspectdb.py U django/contrib/admin/options.py U django/contrib/admin/templatetags/admin_list.py U django/contrib/admin/widgets.py U django/contrib/admin/sites.py U django/contrib/admin/templates/admin/edit_inline/tabular.html U django/contrib/admin/templates/admin/delete_selected_confirmation.html U django/contrib/auth/tests/__init__.py U django/contrib/auth/decorators.py U django/contrib/localflavor/fr/forms.py U tests/modeltests/expressions/models.py U tests/regressiontests/admin_views/fixtures/admin-views-person.xml U tests/regressiontests/admin_views/tests.py U tests/regressiontests/decorators/tests.py U tests/regressiontests/forms/error_messages.py U tests/regressiontests/templates/filters.py U tests/regressiontests/introspection/tests.py U tests/regressiontests/backends/tests.py U tests/regressiontests/queries/models.py U AUTHORS U extras/django_bash_completion U docs/index.txt U docs/intro/tutorial01.txt A docs/internals/svn.txt U docs/internals/index.txt U docs/howto/deployment/modpython.txt U docs/howto/deployment/modwsgi.txt U docs/howto/static-files.txt U docs/topics/http/sessions.txt U docs/topics/http/shortcuts.txt U docs/topics/auth.txt U docs/topics/generic-views.txt U docs/topics/db/queries.txt U docs/topics/forms/modelforms.txt U docs/releases/1.1.txt U docs/ref/contrib/formtools/form-wizard.txt U docs/ref/contrib/comments/index.txt U docs/ref/contrib/admin/index.txt U docs/ref/request-response.txt U docs/ref/models/querysets.txt U docs/ref/models/fields.txt U docs/ref/databases.txt U docs/ref/forms/widgets.txt U docs/ref/signals.txt Updated to revision 11593. termie@termie:~/p/django % ls 15:48:11 AUTHORS INSTALL LICENSE MANIFEST.in README django docs examples extras scripts setup.cfg setup.py tests termie@termie:~/p/django % cd tests 15:48:12 termie@termie:p/django/tests % ls 15:48:14 modeltests regressiontests runtests.py templates urls.py termie@termie:p/django/tests % python runtests.py 15:48:14 Usage: runtests.py [options] [model model model ...] runtests.py: error: DJANGO_SETTINGS_MODULE is not set in the environment. Set it or use --settings. termie@termie:p/django/tests % vim settings.py 15:48:18 termie@termie:p/django/tests % python runtests.py 15:48:30 Usage: runtests.py [options] [model model model ...] runtests.py: error: DJANGO_SETTINGS_MODULE is not set in the environment. Set it or use --settings. termie@termie:p/django/tests % python runtests.py --settings settings 15:48:31 Traceback (most recent call last): File "runtests.py", line 191, in <module> django_tests(int(options.verbosity), options.interactive, args) File "runtests.py", line 121, in django_tests from django.db.models.loading import get_apps, load_app File "/home/termie/lib/python/django/db/__init__.py", line 34, in <module> (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends)), e_user) django.core.exceptions.ImproperlyConfigured: 'sqlite' isn't an available database backend. Available options are: 'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' Error was: No module named sqlite.base termie@termie:p/django/tests % vim settings.py 15:49:03 termie@termie:p/django/tests % python runtests.py --settings settings 15:49:11 Error while importing proxy_models: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/modeltests/proxy_models/models.py", line 42, in <module> class MyPerson(Person): File "/home/termie/lib/python/django/db/models/base.py", line 55, in __new__ new_class.add_to_class('_meta', Options(meta, **kwargs)) File "/home/termie/lib/python/django/db/models/base.py", line 165, in add_to_class value.contribute_to_class(cls, name) File "/home/termie/lib/python/django/db/models/options.py", line 92, in contribute_to_class raise TypeError, "'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) TypeError: 'class Meta' got invalid attribute(s): proxy Error while importing defer: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/modeltests/defer/models.py", line 6, in <module> from django.db.models.query_utils import DeferredAttribute ImportError: cannot import name DeferredAttribute Error while importing unmanaged_models: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/modeltests/unmanaged_models/models.py", line 20, in <module> class B01(models.Model): File "/home/termie/lib/python/django/db/models/base.py", line 55, in __new__ new_class.add_to_class('_meta', Options(meta, **kwargs)) File "/home/termie/lib/python/django/db/models/base.py", line 165, in add_to_class value.contribute_to_class(cls, name) File "/home/termie/lib/python/django/db/models/options.py", line 92, in contribute_to_class raise TypeError, "'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) TypeError: 'class Meta' got invalid attribute(s): managed Error while importing conditional_processing: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/regressiontests/conditional_processing/models.py", line 6, in <module> from django.utils.http import parse_etags, quote_etag ImportError: cannot import name parse_etags Error while importing test_client_regress: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/regressiontests/test_client_regress/models.py", line 9, in <module> from django.test.utils import ContextList ImportError: cannot import name ContextList Error while importing fixtures_regress: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/regressiontests/fixtures_regress/models.py", line 72, in <module> class WidgetProxy(Widget): File "/home/termie/lib/python/django/db/models/base.py", line 55, in __new__ new_class.add_to_class('_meta', Options(meta, **kwargs)) File "/home/termie/lib/python/django/db/models/base.py", line 165, in add_to_class value.contribute_to_class(cls, name) File "/home/termie/lib/python/django/db/models/options.py", line 92, in contribute_to_class raise TypeError, "'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) TypeError: 'class Meta' got invalid attribute(s): proxy Error while importing delete_regress: File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/usr/local/google/home/p/django/tests/regressiontests/delete_regress/models.py", line 4, in <module> from django.test import TransactionTestCase ImportError: cannot import name TransactionTestCase Traceback (most recent call last): File "runtests.py", line 191, in <module> django_tests(int(options.verbosity), options.interactive, args) File "runtests.py", line 134, in django_tests mod = load_app(model_label) File "/home/termie/lib/python/django/db/models/loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "/home/termie/lib/python/django/contrib/webdesign/__init__.py", line 1, in <module> KeyboardInterrupt python runtests.py --settings settings 0.76s user 0.26s system 14% cpu 6.995 total termie@termie:p/django/tests % ln -s ../django ./ termie@termie:p/django/tests % python runtests.py --settings settings ...
Was all that really necessary?
Change History (3)
comment:1 by , 15 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
reopening, this is not only about settings.py and databases, it is also:
the django being tested against incorrectly defaults to whatever django is first on your path rather than the checkout, the tests in the checkout are obviously written for the code in the checkout and are very unlikely to work with your installed version of django
additionally, these is no need for the extra --settings command-flag, the default of looking at settings.py in current directory is perfectly adequate and should you want to test with different settings using the settings flag is easy enough, adding a message like "testing with settings.py, to change this use --settings" would leave the feature with good discoverability.
regarding assumed defaults there is quite obviously such a thing even if in this instance it might be preferable to make the choice of databases a more conscious one, I am happy to leave that argument for the other issue.
comment:3 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
As I noted in my comment, and as has been noted in #6298, the extra --settings flag _is_ required. It isn't required for technical reasons, it's required for social reasons.
I don't see that there is much we can do about the path problem. If you've set up your python environment so that a remote install takes priority over the local directory, there isn't much we can do to help.
Regardless, if you disagree with a decision made by a core developer, don't just reopen the ticket - start a discussion on django-dev to make your case.
This is an exact duplicate of #6298.
I'm _deeply_ opposed to assumed defaults, because there's no such thing. When you run the test system, it isn't enough to just run it for SQLite - you need to run it for _all_ databases. I appreciate that this isn't always possible for first-time users, but I want people to be _consciously_ made aware of the fact that they are running the test suite for a _specific_ configuration.