1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #14508 - test suite silences warnings.

Utility functions get_warnings_state and save_warnings_state have been added
to django.test.utils, and methods to django.test.TestCase for convenience.

The implementation is based on the catch_warnings context manager from
Python 2.6.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14526 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant
2010-11-11 15:06:20 +00:00
parent 7beca4d3e5
commit 02fc6276d7
10 changed files with 87 additions and 25 deletions

View File

@@ -20,6 +20,7 @@ from django.template import TemplateDoesNotExist, Context
from django.template.loaders.eggs import load_template_source as lts_egg
from django.template.loaders.eggs import Loader as EggLoader
from django.template import loader
from django.test.utils import get_warnings_state, restore_warnings_state
from django.utils import unittest
@@ -68,13 +69,13 @@ class DeprecatedEggLoaderTest(unittest.TestCase):
})
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
warnings.resetwarnings()
warnings.simplefilter("ignore", PendingDeprecationWarning)
restore_warnings_state(self._warnings_state)
def test_existing(self):
"A template can be loaded from an egg"