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
|
# 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
|
# 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
|
# 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
|
# managed during each test. We also set them to use the same tables as the
|
||||||
# setUpClass and tearDownClass because they're called before Django flushes the
|
# "reference" models to avoid errors when other tests run 'syncdb'
|
||||||
# tables, so Django attempts to flush a non-existing table.
|
# (proxy_models_inheritance does).
|
||||||
|
|
||||||
class ScientistRef(models.Model):
|
class ScientistRef(models.Model):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
|
@ -19,6 +19,7 @@ class ArticleRef(models.Model):
|
||||||
class Scientist(models.Model):
|
class Scientist(models.Model):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
class Meta:
|
class Meta:
|
||||||
|
db_table = 'tablespaces_scientistref'
|
||||||
db_tablespace = 'tbl_tbsp'
|
db_tablespace = 'tbl_tbsp'
|
||||||
managed = False
|
managed = False
|
||||||
|
|
||||||
|
@ -28,5 +29,14 @@ class Article(models.Model):
|
||||||
authors = models.ManyToManyField(Scientist, related_name='articles_written_set')
|
authors = models.ManyToManyField(Scientist, related_name='articles_written_set')
|
||||||
reviewers = models.ManyToManyField(Scientist, related_name='articles_reviewed_set', db_tablespace='idx_tbsp')
|
reviewers = models.ManyToManyField(Scientist, related_name='articles_reviewed_set', db_tablespace='idx_tbsp')
|
||||||
class Meta:
|
class Meta:
|
||||||
|
db_table = 'tablespaces_articleref'
|
||||||
db_tablespace = 'tbl_tbsp'
|
db_tablespace = 'tbl_tbsp'
|
||||||
managed = False
|
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.core.management.color import no_style
|
||||||
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||||
|
|
||||||
from models import Article, ArticleRef, Scientist, ScientistRef
|
from models import Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef
|
||||||
|
|
||||||
# Automatically created models
|
|
||||||
Authors = Article._meta.get_field('authors').rel.through
|
|
||||||
Reviewers = Article._meta.get_field('reviewers').rel.through
|
|
||||||
|
|
||||||
# We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings
|
# 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,
|
# because they're evaluated when the model class is defined. As a consequence,
|
||||||
|
@ -27,7 +23,7 @@ class TablespacesTests(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# The unmanaged models need to be removed after the test in order to
|
# 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_models = copy.deepcopy(cache.app_models)
|
||||||
self.old_app_store = copy.deepcopy(cache.app_store)
|
self.old_app_store = copy.deepcopy(cache.app_store)
|
||||||
|
|
||||||
|
@ -56,7 +52,7 @@ class TablespacesTests(TestCase):
|
||||||
def test_tablespace_ignored_for_model(self):
|
def test_tablespace_ignored_for_model(self):
|
||||||
# No tablespace-related SQL
|
# No tablespace-related SQL
|
||||||
self.assertEqual(sql_for_table(Scientist),
|
self.assertEqual(sql_for_table(Scientist),
|
||||||
sql_for_table(ScientistRef).replace('ref', ''))
|
sql_for_table(ScientistRef))
|
||||||
|
|
||||||
@skipUnlessDBFeature('supports_tablespaces')
|
@skipUnlessDBFeature('supports_tablespaces')
|
||||||
def test_tablespace_for_indexed_field(self):
|
def test_tablespace_for_indexed_field(self):
|
||||||
|
@ -69,7 +65,7 @@ class TablespacesTests(TestCase):
|
||||||
def test_tablespace_ignored_for_indexed_field(self):
|
def test_tablespace_ignored_for_indexed_field(self):
|
||||||
# No tablespace-related SQL
|
# No tablespace-related SQL
|
||||||
self.assertEqual(sql_for_table(Article),
|
self.assertEqual(sql_for_table(Article),
|
||||||
sql_for_table(ArticleRef).replace('ref', ''))
|
sql_for_table(ArticleRef))
|
||||||
|
|
||||||
@skipUnlessDBFeature('supports_tablespaces')
|
@skipUnlessDBFeature('supports_tablespaces')
|
||||||
def test_tablespace_for_many_to_many_field(self):
|
def test_tablespace_for_many_to_many_field(self):
|
||||||
|
|
Loading…
Reference in New Issue