#16593: Quick fix for proxy_model_inheritance tests
----------------------------+----------------------------------------------
Reporter: jsdalton | Owner: nobody
Type: | Status: new
Cleanup/optimization | Component: Database layer (models, ORM)
Milestone: | Severity: Normal
Version: SVN | Triage Stage: Unreviewed
Keywords: | Easy pickings: 1
Has patch: 0 |
UI/UX: 0 |
----------------------------+----------------------------------------------
The error I just now reported in #16592 revealed another fairly minor
problem with the proxy_model_inheritance tests which should be easy to
fix.
The test is exercising the syncdb command and then verifying the existence
of certain tables. However, the call to syncdb is being made in the
`setUp()` method instead of the test case itself. As a result, if there is
an error when executing it (as happens with #16592), the tearDown() method
is not called. This means the remainder of the test suite will be executed
with a modified sys.path and settings.INSTALLED_APPS. Sure enough, this
causes some other unrelated failures which do not occur when the tests are
run in isolation.
Reproduce it with:
{{{
$ ./runtests.py --settings=testproject.settings unmanaged_models
proxy_model_inheritance bug8245
Creating test database for alias 'default'...
Creating test database for alias 'other'...
...EF
======================================================================
ERROR: test_table_exists
(modeltests.proxy_model_inheritance.tests.ProxyModelInheritanceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/jsdalton/webs/testproject/src/django/tests/modeltests/proxy_model_inheritance/tests.py",
line 25, in setUp
call_command('syncdb', verbosity=0)
File
"/Users/jsdalton/webs/testproject/src/django/django/core/management/__init__.py",
line 166, in call_command
return klass.execute(*args, **defaults)
File
"/Users/jsdalton/webs/testproject/src/django/django/core/management/base.py",
line 220, in execute
output = self.handle(*args, **options)
File
"/Users/jsdalton/webs/testproject/src/django/django/core/management/base.py",
line 351, in handle
return self.handle_noargs(**options)
File
"/Users/jsdalton/webs/testproject/src/django/django/core/management/commands/syncdb.py",
line 121, in handle_noargs
custom_sql = custom_sql_for_model(model, self.style, connection)
File
"/Users/jsdalton/webs/testproject/src/django/django/core/management/sql.py",
line 150, in custom_sql_for_model
app_dir =
os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__),
'sql'))
File
"/Users/jsdalton/webs/testproject/src/django/django/db/models/loading.py",
line 151, in get_app
raise ImproperlyConfigured("App with label %s could not be found" %
app_label)
ImproperlyConfigured: App with label unmanaged_models could not be found
======================================================================
FAIL: test_bug_8245 (regressiontests.bug8245.tests.Bug8245Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/jsdalton/webs/testproject/src/django/tests/regressiontests/bug8245/tests.py",
line 18, in test_bug_8245
'autodiscover should have raised a "Bad admin module" error.')
AssertionError: autodiscover should have raised a "Bad admin module"
error.
----------------------------------------------------------------------
Ran 5 tests in 2.417s
FAILED (failures=1, errors=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
}}}
That second failure seems to be caused by the test structure.
The attached patch moves the call where it should be (part of the test
case) and resolves the issue. A minor cleanup, but will save other
developers time in the future if a regression occurs.
--
Ticket URL: <https://code.djangoproject.com/ticket/16593>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.