home / django_tickets / tickets

tickets: 16593

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
16593 2011-08-08 15:06:03 2011-08-10 22:34:45 2022-03-06 04:03:37.348216 Unreviewed closed Database layer (models, ORM) Cleanup/optimization Normal dev fixed Quick fix for proxy_model_inheritance tests 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. nobody jsdalton   1 0       0
Powered by Datasette · Queries took 0.914ms