Kaydet (Commit) f05b03f3 authored tarafından Claude Paroz's avatar Claude Paroz

Removed model_package test dependency on contrib.sites

üst f233bf47
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)
......
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment