1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Updates to the test suite to allow for newly deprecated and removed features

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15990 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2011-04-02 08:44:47 +00:00
parent 603884505f
commit 4c468800ee
28 changed files with 255 additions and 298 deletions

View File

@@ -57,33 +57,6 @@ def create_egg(name, resources):
egg._resources = resources
sys.modules[name] = egg
class DeprecatedEggLoaderTest(unittest.TestCase):
"Test the deprecated load_template_source interface to the egg loader"
def setUp(self):
pkg_resources._provider_factories[MockLoader] = MockProvider
self.empty_egg = create_egg("egg_empty", {})
self.egg_1 = create_egg("egg_1", {
os.path.normcase('templates/y.html') : StringIO.StringIO("y"),
os.path.normcase('templates/x.txt') : StringIO.StringIO("x"),
})
self._old_installed_apps = settings.INSTALLED_APPS
settings.INSTALLED_APPS = []
self._warnings_state = get_warnings_state()
warnings.filterwarnings("ignore", category=DeprecationWarning,
module='django.template.loaders.eggs')
def tearDown(self):
settings.INSTALLED_APPS = self._old_installed_apps
restore_warnings_state(self._warnings_state)
def test_existing(self):
"A template can be loaded from an egg"
settings.INSTALLED_APPS = ['egg_1']
contents, template_name = lts_egg("y.html")
self.assertEqual(contents, "y")
self.assertEqual(template_name, "egg:egg_1:templates/y.html")
class EggLoaderTest(unittest.TestCase):
def setUp(self):

View File

@@ -11,12 +11,14 @@ import time
import os
import sys
import traceback
import warnings
from django import template
from django.template import base as template_base
from django.core import urlresolvers
from django.template import loader
from django.template.loaders import app_directories, filesystem, cached
from django.test.utils import get_warnings_state, restore_warnings_state
from django.utils import unittest
from django.utils.translation import activate, deactivate, ugettext as _
from django.utils.safestring import mark_safe
@@ -137,6 +139,10 @@ class UTF8Class:
class Templates(unittest.TestCase):
def setUp(self):
self._warnings_state = get_warnings_state()
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.template.defaulttags')
self.old_static_url = settings.STATIC_URL
self.old_media_url = settings.MEDIA_URL
settings.STATIC_URL = u"/static/"
@@ -145,6 +151,7 @@ class Templates(unittest.TestCase):
def tearDown(self):
settings.STATIC_URL = self.old_static_url
settings.MEDIA_URL = self.old_media_url
restore_warnings_state(self._warnings_state)
def test_loaders_security(self):
ad_loader = app_directories.Loader()