Fixed a test failure introduced at r16987. Refs #12308.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16988 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
246580573d
commit
a8e1d134a5
|
@ -3,9 +3,9 @@ from django.db import models
|
|||
# Since the test database doesn't have tablespaces, it's impossible for Django
|
||||
# to create the tables for models where db_tablespace is set. To avoid this
|
||||
# problem, we mark the models as unmanaged, and temporarily revert them to
|
||||
# managed during each tes. See setUp and tearDown -- it isn't possible to use
|
||||
# setUpClass and tearDownClass because they're called before Django flushes the
|
||||
# tables, so Django attempts to flush a non-existing table.
|
||||
# managed during each test. We also set them to use the same tables as the
|
||||
# "reference" models to avoid errors when other tests run 'syncdb'
|
||||
# (proxy_models_inheritance does).
|
||||
|
||||
class ScientistRef(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
|
@ -19,6 +19,7 @@ class ArticleRef(models.Model):
|
|||
class Scientist(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
class Meta:
|
||||
db_table = 'tablespaces_scientistref'
|
||||
db_tablespace = 'tbl_tbsp'
|
||||
managed = False
|
||||
|
||||
|
@ -28,5 +29,14 @@ class Article(models.Model):
|
|||
authors = models.ManyToManyField(Scientist, related_name='articles_written_set')
|
||||
reviewers = models.ManyToManyField(Scientist, related_name='articles_reviewed_set', db_tablespace='idx_tbsp')
|
||||
class Meta:
|
||||
db_table = 'tablespaces_articleref'
|
||||
db_tablespace = 'tbl_tbsp'
|
||||
managed = False
|
||||
|
||||
# Also set the tables for automatically created models
|
||||
|
||||
Authors = Article._meta.get_field('authors').rel.through
|
||||
Authors._meta.db_table = 'tablespaces_articleref_authors'
|
||||
|
||||
Reviewers = Article._meta.get_field('reviewers').rel.through
|
||||
Reviewers._meta.db_table = 'tablespaces_articleref_reviewers'
|
||||
|
|
|
@ -6,11 +6,7 @@ from django.db.models.loading import cache
|
|||
from django.core.management.color import no_style
|
||||
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||
|
||||
from models import Article, ArticleRef, Scientist, ScientistRef
|
||||
|
||||
# Automatically created models
|
||||
Authors = Article._meta.get_field('authors').rel.through
|
||||
Reviewers = Article._meta.get_field('reviewers').rel.through
|
||||
from models import Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef
|
||||
|
||||
# We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings
|
||||
# because they're evaluated when the model class is defined. As a consequence,
|
||||
|
@ -27,7 +23,7 @@ class TablespacesTests(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
# The unmanaged models need to be removed after the test in order to
|
||||
# prevent bad interactions with other tests (proxy_models_inheritance).
|
||||
# prevent bad interactions with the flush operation in other tests.
|
||||
self.old_app_models = copy.deepcopy(cache.app_models)
|
||||
self.old_app_store = copy.deepcopy(cache.app_store)
|
||||
|
||||
|
@ -56,7 +52,7 @@ class TablespacesTests(TestCase):
|
|||
def test_tablespace_ignored_for_model(self):
|
||||
# No tablespace-related SQL
|
||||
self.assertEqual(sql_for_table(Scientist),
|
||||
sql_for_table(ScientistRef).replace('ref', ''))
|
||||
sql_for_table(ScientistRef))
|
||||
|
||||
@skipUnlessDBFeature('supports_tablespaces')
|
||||
def test_tablespace_for_indexed_field(self):
|
||||
|
@ -69,7 +65,7 @@ class TablespacesTests(TestCase):
|
|||
def test_tablespace_ignored_for_indexed_field(self):
|
||||
# No tablespace-related SQL
|
||||
self.assertEqual(sql_for_table(Article),
|
||||
sql_for_table(ArticleRef).replace('ref', ''))
|
||||
sql_for_table(ArticleRef))
|
||||
|
||||
@skipUnlessDBFeature('supports_tablespaces')
|
||||
def test_tablespace_for_many_to_many_field(self):
|
||||
|
|
Loading…
Reference in New Issue