summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorMarkus Holtermann <info@markusholtermann.eu>2015-01-22 04:26:37 +0100
committerMarkus Holtermann <info@markusholtermann.eu>2015-02-13 14:39:50 +0100
commit45d93baf518218c39b70fbc1eb35e9b53f66cf98 (patch)
tree32affba9024070a8d77335c944a11a4c029e4f77 /tests/postgres_tests/test_array.py
parent4c948c7c9d8b8bb4a36f703a6e96de5914740b0f (diff)
[1.8.x] Refs #22962 -- Made test case use non-conflicting table names
Backport of b06935a486e633e9732bce2bc5f796eb437b2531 from master
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 8edc78d65c..770d5a1623 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -9,7 +9,7 @@ from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField
from django.core import exceptions, serializers
from django.core.management import call_command
from django.db import IntegrityError, connection, models
-from django.test import TestCase, override_settings
+from django.test import TestCase, TransactionTestCase, override_settings
from django.utils import timezone
from .models import (
@@ -243,7 +243,9 @@ class TestChecks(TestCase):
self.assertEqual(errors[0].id, 'postgres.E002')
-class TestMigrations(TestCase):
+class TestMigrations(TransactionTestCase):
+
+ available_apps = ['postgres_tests']
def test_deconstruct(self):
field = ArrayField(models.IntegerField())
@@ -278,7 +280,15 @@ class TestMigrations(TestCase):
})
def test_adding_field_with_default(self):
# See #22962
+ table_name = 'postgres_tests_integerarraydefaultmodel'
+ with connection.cursor() as cursor:
+ self.assertNotIn(table_name, connection.introspection.table_names(cursor))
call_command('migrate', 'postgres_tests', verbosity=0)
+ with connection.cursor() as cursor:
+ self.assertIn(table_name, connection.introspection.table_names(cursor))
+ call_command('migrate', 'postgres_tests', 'zero', verbosity=0)
+ with connection.cursor() as cursor:
+ self.assertNotIn(table_name, connection.introspection.table_names(cursor))
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL required')