summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-11-09 19:09:36 -0500
committerGitHub <noreply@github.com>2018-11-09 19:09:36 -0500
commitf82be9ebc79e30fef796bbc61fec4b9694cb779f (patch)
treec4a5907223c04a3f005612543abea418234afe5c /tests
parentf9ff1df1daac8ae1fc22b27f48735148cb5488dd (diff)
Fixed #29934 -- Added sqlparse as a require dependency.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_commands.py34
-rw-r--r--tests/migrations/test_multidb.py9
-rw-r--r--tests/migrations/test_operations.py9
3 files changed, 13 insertions, 39 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index 63e8615e67..2548804677 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -20,11 +20,6 @@ from .models import UnicodeModel, UnserializableModel
from .routers import TestRouter
from .test_base import MigrationTestBase
-try:
- import sqlparse
-except ImportError:
- sqlparse = None
-
class MigrateTests(MigrationTestBase):
"""
@@ -355,22 +350,19 @@ class MigrateTests(MigrationTestBase):
out.getvalue()
)
# Show the plan when an operation is irreversible.
- # Migration 0004's RunSQL uses a SQL string instead of a list, so
- # sqlparse may be required for splitting.
- if sqlparse or not connection.features.requires_sqlparse_for_splitting:
- # Migrate to the fourth migration.
- call_command('migrate', 'migrations', '0004', verbosity=0)
- out = io.StringIO()
- call_command('migrate', 'migrations', '0003', plan=True, stdout=out, no_color=True)
- self.assertEqual(
- 'Planned operations:\n'
- 'migrations.0004_fourth\n'
- ' Raw SQL operation -> IRREVERSIBLE\n',
- out.getvalue()
- )
- # Cleanup by unmigrating everything: fake the irreversible, then
- # migrate all to zero.
- call_command('migrate', 'migrations', '0003', fake=True, verbosity=0)
+ # Migrate to the fourth migration.
+ call_command('migrate', 'migrations', '0004', verbosity=0)
+ out = io.StringIO()
+ call_command('migrate', 'migrations', '0003', plan=True, stdout=out, no_color=True)
+ self.assertEqual(
+ 'Planned operations:\n'
+ 'migrations.0004_fourth\n'
+ ' Raw SQL operation -> IRREVERSIBLE\n',
+ out.getvalue()
+ )
+ # Cleanup by unmigrating everything: fake the irreversible, then
+ # migrate all to zero.
+ call_command('migrate', 'migrations', '0003', fake=True, verbosity=0)
call_command('migrate', 'migrations', 'zero', verbosity=0)
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_empty'})
diff --git a/tests/migrations/test_multidb.py b/tests/migrations/test_multidb.py
index 16cd8f33d1..0bed042964 100644
--- a/tests/migrations/test_multidb.py
+++ b/tests/migrations/test_multidb.py
@@ -1,16 +1,9 @@
-import unittest
-
from django.db import connection, migrations, models
from django.db.migrations.state import ProjectState
from django.test import override_settings
from .test_operations import OperationTestBase
-try:
- import sqlparse
-except ImportError:
- sqlparse = None
-
class AgnosticRouter:
"""
@@ -128,12 +121,10 @@ class MultiDBOperationTests(OperationTestBase):
else:
self.assertEqual(Pony.objects.count(), 0)
- @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse")
@override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()])
def test_run_sql(self):
self._test_run_sql("test_mltdb_runsql", should_run=False)
- @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse")
@override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()])
def test_run_sql2(self):
self._test_run_sql("test_mltdb_runsql2", should_run=False)
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 117b124ae4..2f35b5ba8f 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -1,5 +1,3 @@
-import unittest
-
from django.core.exceptions import FieldDoesNotExist
from django.db import connection, migrations, models, transaction
from django.db.migrations.migration import Migration
@@ -14,11 +12,6 @@ from django.test import SimpleTestCase, override_settings, skipUnlessDBFeature
from .models import FoodManager, FoodQuerySet, UnicodeModel
from .test_base import MigrationTestBase
-try:
- import sqlparse
-except ImportError:
- sqlparse = None
-
class Mixin:
pass
@@ -2051,7 +2044,6 @@ class OperationTests(OperationTestBase):
self.assertColumnExists("test_afknfk_rider", "pony_id")
self.assertColumnNotExists("test_afknfk_rider", "pony")
- @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse")
def test_run_sql(self):
"""
Tests the RunSQL operation.
@@ -2561,7 +2553,6 @@ class OperationTests(OperationTestBase):
operation.database_forwards("test_runpython", editor, project_state, new_state)
operation.database_backwards("test_runpython", editor, new_state, project_state)
- @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse")
def test_separate_database_and_state(self):
"""
Tests the SeparateDatabaseAndState operation.