Removed model_package test dependency on contrib.sites

This commit is contained in:
Claude Paroz 2014-12-23 18:09:55 +01:00
parent f233bf47dd
commit f05b03f3d7
2 changed files with 7 additions and 13 deletions

View File

@ -1,7 +1,10 @@
from django.contrib.sites.models import Site
from django.db import models
class Site(models.Model):
name = models.CharField(max_length=100)
class Article(models.Model):
sites = models.ManyToManyField(Site)
headline = models.CharField(max_length=100)

View File

@ -1,12 +1,11 @@
from __future__ import unicode_literals
from django.contrib.sites.models import Site
from django.db import models, connection
from django.db.backends.utils import truncate_name
from django.test import TestCase
from .models.publication import Publication
from .models.article import Article
from .models.article import Article, Site
class Advertisement(models.Model):
@ -16,13 +15,6 @@ class Advertisement(models.Model):
class ModelPackageTests(TestCase):
@classmethod
def setUpClass(cls):
super(ModelPackageTests, cls).setUpClass()
# This cleanup is necessary because contrib.sites cache
# makes tests interfere with each other, see #11505
Site.objects.clear_cache()
def test_m2m_tables_in_subpackage_models(self):
"""
Regression for #12168: models split into subpackages still get M2M
@ -30,12 +22,11 @@ class ModelPackageTests(TestCase):
"""
p = Publication.objects.create(title="FooBar")
current_site = Site.objects.get_current()
self.assertEqual(current_site.domain, "example.com")
site = Site.objects.create(name="example.com")
a = Article.objects.create(headline="a foo headline")
a.publications.add(p)
a.sites.add(current_site)
a.sites.add(site)
a = Article.objects.get(id=a.pk)
self.assertEqual(a.id, a.pk)