Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #14447 -- Modified the auth and sitemaps tests to remove some a…

…ssumptions about the environment in which the tests are run. Thanks to Gabriel Hurley for the report and patch.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 5506653 commit 03f00bcd4240f13e6ffe5d8b6688b8a289cb6f8f @freakboy3742 freakboy3742 committed
7 django/contrib/auth/tests/
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.tests.views import AuthViewsTestCase
@@ -15,7 +16,7 @@ class CallableView(object):
def __call__(self, *args, **kwargs):
def testView(self):
Check that login_required is assignable to normal views.
@@ -24,7 +25,7 @@ def normal_view(request):
- def testLoginRequired(self, view_url='/login_required/', login_url='/login/'):
+ def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGIN_URL):
Check that login_required works on a simple view wrapped in a
login_required decorator.
@@ -42,4 +43,4 @@ def testLoginRequiredNextUrl(self):
login_required decorator with a login_url set.
- login_url='/somewhere/')
+ login_url='/somewhere/')
19 django/contrib/sitemaps/tests/
@@ -1,11 +1,11 @@
from datetime import date
from django.conf import settings
from django.contrib.auth.models import User
-from django.contrib.flatpages.models import FlatPage
from django.contrib.sitemaps import Sitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
+from django.utils.unittest import skipUnless
from django.utils.formats import localize
from django.utils.translation import activate, deactivate
@@ -52,15 +52,27 @@ def test_generic_sitemap(self):
"A minimal generic sitemap can be rendered"
# Retrieve the sitemap.
response = self.client.get('/generic/sitemap.xml')
+ expected = ''
+ for username in User.objects.values_list("username", flat=True):
+ expected += "<url><loc></loc></url>" %username
# Check for all the important bits:
self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="">
+""" %expected)
+ @skipUnless("django.contrib.flatpages" in settings.INSTALLED_APPS, "django.contrib.flatpages app not installed.")
def test_flatpage_sitemap(self):
"Basic FlatPage sitemap test"
+ # Import FlatPage inside the test so that when django.contrib.flatpages
+ # is not installed we don't get problems trying to delete Site
+ # objects (FlatPage has an M2M to Site, Site.delete() tries to
+ # delete related objects, but the M2M table doesn't exist.
+ from django.contrib.flatpages.models import FlatPage
public = FlatPage.objects.create(
title=u'Public Page',
@@ -85,7 +97,6 @@ def test_requestsite_sitemap(self):
# Make sure hitting the flatpages sitemap without the sites framework
# installed doesn't raise an exception
Site._meta.installed = False
- response = self.client.get('/flatpages/sitemap.xml')
# Retrieve the sitemap.
response = self.client.get('/simple/sitemap.xml')
# Check for all the important bits:

0 comments on commit 03f00bc

Please sign in to comment.
Something went wrong with that request. Please try again.