mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #30595 -- Added error message when no objects found to sql* management commands.
This commit is contained in:
parent
c2f381ef17
commit
5d03f2bc01
9 changed files with 38 additions and 1 deletions
0
tests/empty_models/__init__.py
Normal file
0
tests/empty_models/__init__.py
Normal file
0
tests/empty_models/models.py
Normal file
0
tests/empty_models/models.py
Normal file
18
tests/empty_models/test_commands.py
Normal file
18
tests/empty_models/test_commands.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import io
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class CoreCommandsNoOutputTests(TestCase):
|
||||
available_apps = ['empty_models']
|
||||
|
||||
def test_sqlflush_no_tables(self):
|
||||
err = io.StringIO()
|
||||
call_command('sqlflush', stderr=err)
|
||||
self.assertEqual(err.getvalue(), 'No tables found.\n')
|
||||
|
||||
def test_sqlsequencereset_no_sequences(self):
|
||||
err = io.StringIO()
|
||||
call_command('sqlsequencereset', 'empty_models', stderr=err)
|
||||
self.assertEqual(err.getvalue(), 'No sequences found.\n')
|
|
@ -645,6 +645,12 @@ class MigrateTests(MigrationTestBase):
|
|||
self.assertNotIn(start_transaction_sql.lower(), queries)
|
||||
self.assertNotIn(connection.ops.end_transaction_sql().lower(), queries)
|
||||
|
||||
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_no_operations'})
|
||||
def test_migrations_no_operations(self):
|
||||
err = io.StringIO()
|
||||
call_command('sqlmigrate', 'migrations', '0001_initial', stderr=err)
|
||||
self.assertEqual(err.getvalue(), 'No operations found.\n')
|
||||
|
||||
@override_settings(
|
||||
INSTALLED_APPS=[
|
||||
"migrations.migrations_test_apps.migrated_app",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = []
|
||||
operations = []
|
Loading…
Add table
Add a link
Reference in a new issue