From f05b03f3d7e23fcbb896fd7c6f79140b89617741 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 23 Dec 2014 18:09:55 +0100 Subject: [PATCH] Removed model_package test dependency on contrib.sites --- tests/model_package/models/article.py | 5 ++++- tests/model_package/tests.py | 15 +++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/model_package/models/article.py b/tests/model_package/models/article.py index 98ee3cd740..f664dc08c5 100644 --- a/tests/model_package/models/article.py +++ b/tests/model_package/models/article.py @@ -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) diff --git a/tests/model_package/tests.py b/tests/model_package/tests.py index 84b1dd1c30..c0a65b2ad6 100644 --- a/tests/model_package/tests.py +++ b/tests/model_package/tests.py @@ -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)