Loading django/core/management/sql.py +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ def sql_delete(app_config, style, connection, close_connection=True): cursor.close() connection.close() if not output: output.append('-- App creates no tables in the database. Nothing to do.') return output[::-1] # Reverse it, to deal with table dependencies. Loading tests/admin_scripts/tests.py +9 −1 Original line number Diff line number Diff line Loading @@ -297,7 +297,8 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase): contains the test application specified using a full path. """ def setUp(self): self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']) self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts', 'admin_scripts.complex_app']) def tearDown(self): self.remove_settings('settings.py') Loading @@ -316,6 +317,13 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase): self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE') def test_sqlclear_builtin_with_settings(self): "fulldefault: django-admin builtin commands succeed if a setting file is provided" args = ['sqlclear', '--settings=test_project.settings', 'complex_app'] out, err = self.run_django_admin(args) self.assertNoOutput(err) self.assertOutput(out, '-- App creates no tables in the database. Nothing to do.') def test_builtin_with_environment(self): "fulldefault: django-admin builtin commands succeed if the environment contains settings" args = ['sqlall', 'admin_scripts'] Loading tests/commands_sql/tests.py +4 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,10 @@ class SQLCommandsRouterTestCase(TestCase): for sql_command in (sql_all, sql_create, sql_delete, sql_indexes, sql_destroy_indexes): if sql_command is sql_delete: output = sql_command(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False) # "App creates no tables in the database. Nothing to do." expected_output = 1 else: output = sql_command(app_config, no_style(), connections[DEFAULT_DB_ALIAS]) self.assertEqual(len(output), 0, expected_output = 0 self.assertEqual(len(output), expected_output, "%s command is not honoring routers" % sql_command.__name__) Loading
django/core/management/sql.py +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ def sql_delete(app_config, style, connection, close_connection=True): cursor.close() connection.close() if not output: output.append('-- App creates no tables in the database. Nothing to do.') return output[::-1] # Reverse it, to deal with table dependencies. Loading
tests/admin_scripts/tests.py +9 −1 Original line number Diff line number Diff line Loading @@ -297,7 +297,8 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase): contains the test application specified using a full path. """ def setUp(self): self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']) self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts', 'admin_scripts.complex_app']) def tearDown(self): self.remove_settings('settings.py') Loading @@ -316,6 +317,13 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase): self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE') def test_sqlclear_builtin_with_settings(self): "fulldefault: django-admin builtin commands succeed if a setting file is provided" args = ['sqlclear', '--settings=test_project.settings', 'complex_app'] out, err = self.run_django_admin(args) self.assertNoOutput(err) self.assertOutput(out, '-- App creates no tables in the database. Nothing to do.') def test_builtin_with_environment(self): "fulldefault: django-admin builtin commands succeed if the environment contains settings" args = ['sqlall', 'admin_scripts'] Loading
tests/commands_sql/tests.py +4 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,10 @@ class SQLCommandsRouterTestCase(TestCase): for sql_command in (sql_all, sql_create, sql_delete, sql_indexes, sql_destroy_indexes): if sql_command is sql_delete: output = sql_command(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False) # "App creates no tables in the database. Nothing to do." expected_output = 1 else: output = sql_command(app_config, no_style(), connections[DEFAULT_DB_ALIAS]) self.assertEqual(len(output), 0, expected_output = 0 self.assertEqual(len(output), expected_output, "%s command is not honoring routers" % sql_command.__name__)