Loading django/contrib/auth/tests/test_views.py +7 −8 Original line number Diff line number Diff line from importlib import import_module import itertools import re import warnings from django.apps import apps from django.conf import settings Loading @@ -15,11 +14,12 @@ from django.contrib.auth.views import login as login_view from django.core import mail from django.core.urlresolvers import reverse, NoReverseMatch from django.http import QueryDict, HttpRequest from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text from django.utils.http import urlquote from django.utils.six.moves.urllib.parse import urlparse, ParseResult from django.utils.translation import LANGUAGE_SESSION_KEY from django.test import TestCase, override_settings from django.test import TestCase, ignore_warnings, override_settings from django.test.utils import patch_logger from django.middleware.csrf import CsrfViewMiddleware from django.contrib.sessions.middleware import SessionMiddleware Loading Loading @@ -154,11 +154,10 @@ class PasswordResetTest(AuthViewsTestCase): self.assertEqual(len(mail.outbox), 1) self.assertEqual("staffmember@example.com", mail.outbox[0].from_email) @ignore_warnings(category=RemovedInDjango20Warning) @override_settings(ALLOWED_HOSTS=['adminsite.com']) def test_admin_reset(self): "If the reset view is marked as being for admin, the HTTP_HOST header is used for a domain override." with warnings.catch_warnings(record=True): warnings.simplefilter("always") response = self.client.post('/admin_password_reset/', {'email': 'staffmember@example.com'}, HTTP_HOST='adminsite.com' Loading django/contrib/gis/tests/geoapp/test_sitemaps.py +10 −12 Original line number Diff line number Diff line Loading @@ -2,14 +2,13 @@ from __future__ import unicode_literals from io import BytesIO from xml.dom import minidom import warnings import zipfile from django.conf import settings from django.contrib.gis.geos import HAS_GEOS from django.contrib.sites.models import Site from django.test import ( TestCase, modify_settings, override_settings, skipUnlessDBFeature TestCase, ignore_warnings, modify_settings, override_settings, skipUnlessDBFeature ) from django.utils.deprecation import RemovedInDjango20Warning Loading @@ -32,11 +31,10 @@ class GeoSitemapTest(TestCase): expected = set(expected) self.assertEqual(actual, expected) @ignore_warnings(category=RemovedInDjango20Warning) def test_geositemap_kml(self): "Tests KML/KMZ geographic sitemaps." for kml_type in ('kml', 'kmz'): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for the sitemaps in urls.py have been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading django/contrib/sessions/tests.py +9 −12 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ import shutil import string import tempfile import unittest import warnings from django.conf import settings from django.contrib.sessions.backends.db import SessionStore as DatabaseSession Loading @@ -20,7 +19,7 @@ from django.core.cache.backends.base import InvalidCacheBackendError from django.core import management from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponse from django.test import TestCase, RequestFactory, override_settings from django.test import TestCase, RequestFactory, ignore_warnings, override_settings from django.test.utils import patch_logger from django.utils import six from django.utils import timezone Loading Loading @@ -393,10 +392,9 @@ class CacheDBSessionTests(SessionTestsMixin, TestCase): with self.assertNumQueries(0): self.assertTrue(self.session.exists(self.session.session_key)) def test_load_overlong_key(self): # Some backends might issue a warning with warnings.catch_warnings(): warnings.simplefilter("ignore") @ignore_warnings(module="django.core.cache.backends.base") def test_load_overlong_key(self): self.session._session_key = (string.ascii_letters + string.digits) * 20 self.assertEqual(self.session.load(), {}) Loading Loading @@ -486,10 +484,9 @@ class CacheSessionTests(SessionTestsMixin, unittest.TestCase): backend = CacheSession def test_load_overlong_key(self): # Some backends might issue a warning with warnings.catch_warnings(): warnings.simplefilter("ignore") @ignore_warnings(module="django.core.cache.backends.base") def test_load_overlong_key(self): self.session._session_key = (string.ascii_letters + string.digits) * 20 self.assertEqual(self.session.load(), {}) Loading django/contrib/sitemaps/tests/test_flatpages.py +4 −4 Original line number Diff line number Diff line Loading @@ -6,13 +6,15 @@ import warnings from django.apps import apps from django.conf import settings from django.contrib.sitemaps import FlatPageSitemap from django.test import SimpleTestCase from django.test import SimpleTestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango19Warning from .base import SitemapTestsBase class FlatpagesSitemapTests(SitemapTestsBase): @ignore_warnings(category=RemovedInDjango19Warning) @skipUnless(apps.is_installed('django.contrib.flatpages'), "django.contrib.flatpages app not installed.") def test_flatpage_sitemap(self): Loading @@ -38,8 +40,6 @@ class FlatpagesSitemapTests(SitemapTestsBase): registration_required=True ) private.sites.add(settings.SITE_ID) with warnings.catch_warnings(): warnings.simplefilter('ignore') response = self.client.get('/flatpages/sitemap.xml') # Public flatpage should be in the sitemap self.assertContains(response, '<loc>%s%s</loc>' % (self.base_url, public.url)) Loading django/contrib/sitemaps/tests/test_http.py +25 −29 Original line number Diff line number Diff line Loading @@ -3,14 +3,13 @@ from __future__ import unicode_literals import os from datetime import date from unittest import skipUnless import warnings from django.apps import apps from django.conf import settings from django.contrib.sitemaps import Sitemap, GenericSitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import modify_settings, override_settings from django.test import ignore_warnings, modify_settings, override_settings from django.utils.deprecation import RemovedInDjango20Warning from django.utils.formats import localize from django.utils._os import upath Loading @@ -21,10 +20,9 @@ from .base import TestModel, SitemapTestsBase class HTTPSitemapTests(SitemapTestsBase): @ignore_warnings(category=RemovedInDjango20Warning) def test_simple_sitemap_index(self): "A simple sitemap index can be rendered" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading @@ -39,14 +37,13 @@ class HTTPSitemapTests(SitemapTestsBase): """ % self.base_url self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @ignore_warnings(category=RemovedInDjango20Warning) @override_settings(TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')], }]) def test_simple_sitemap_custom_index(self): "A simple sitemap index can be rendered with a custom template" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading Loading @@ -196,9 +193,8 @@ class HTTPSitemapTests(SitemapTestsBase): """ % self.base_url self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @ignore_warnings(category=RemovedInDjango20Warning) def test_x_robots_sitemap(self): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading Loading
django/contrib/auth/tests/test_views.py +7 −8 Original line number Diff line number Diff line from importlib import import_module import itertools import re import warnings from django.apps import apps from django.conf import settings Loading @@ -15,11 +14,12 @@ from django.contrib.auth.views import login as login_view from django.core import mail from django.core.urlresolvers import reverse, NoReverseMatch from django.http import QueryDict, HttpRequest from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text from django.utils.http import urlquote from django.utils.six.moves.urllib.parse import urlparse, ParseResult from django.utils.translation import LANGUAGE_SESSION_KEY from django.test import TestCase, override_settings from django.test import TestCase, ignore_warnings, override_settings from django.test.utils import patch_logger from django.middleware.csrf import CsrfViewMiddleware from django.contrib.sessions.middleware import SessionMiddleware Loading Loading @@ -154,11 +154,10 @@ class PasswordResetTest(AuthViewsTestCase): self.assertEqual(len(mail.outbox), 1) self.assertEqual("staffmember@example.com", mail.outbox[0].from_email) @ignore_warnings(category=RemovedInDjango20Warning) @override_settings(ALLOWED_HOSTS=['adminsite.com']) def test_admin_reset(self): "If the reset view is marked as being for admin, the HTTP_HOST header is used for a domain override." with warnings.catch_warnings(record=True): warnings.simplefilter("always") response = self.client.post('/admin_password_reset/', {'email': 'staffmember@example.com'}, HTTP_HOST='adminsite.com' Loading
django/contrib/gis/tests/geoapp/test_sitemaps.py +10 −12 Original line number Diff line number Diff line Loading @@ -2,14 +2,13 @@ from __future__ import unicode_literals from io import BytesIO from xml.dom import minidom import warnings import zipfile from django.conf import settings from django.contrib.gis.geos import HAS_GEOS from django.contrib.sites.models import Site from django.test import ( TestCase, modify_settings, override_settings, skipUnlessDBFeature TestCase, ignore_warnings, modify_settings, override_settings, skipUnlessDBFeature ) from django.utils.deprecation import RemovedInDjango20Warning Loading @@ -32,11 +31,10 @@ class GeoSitemapTest(TestCase): expected = set(expected) self.assertEqual(actual, expected) @ignore_warnings(category=RemovedInDjango20Warning) def test_geositemap_kml(self): "Tests KML/KMZ geographic sitemaps." for kml_type in ('kml', 'kmz'): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for the sitemaps in urls.py have been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading
django/contrib/sessions/tests.py +9 −12 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ import shutil import string import tempfile import unittest import warnings from django.conf import settings from django.contrib.sessions.backends.db import SessionStore as DatabaseSession Loading @@ -20,7 +19,7 @@ from django.core.cache.backends.base import InvalidCacheBackendError from django.core import management from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponse from django.test import TestCase, RequestFactory, override_settings from django.test import TestCase, RequestFactory, ignore_warnings, override_settings from django.test.utils import patch_logger from django.utils import six from django.utils import timezone Loading Loading @@ -393,10 +392,9 @@ class CacheDBSessionTests(SessionTestsMixin, TestCase): with self.assertNumQueries(0): self.assertTrue(self.session.exists(self.session.session_key)) def test_load_overlong_key(self): # Some backends might issue a warning with warnings.catch_warnings(): warnings.simplefilter("ignore") @ignore_warnings(module="django.core.cache.backends.base") def test_load_overlong_key(self): self.session._session_key = (string.ascii_letters + string.digits) * 20 self.assertEqual(self.session.load(), {}) Loading Loading @@ -486,10 +484,9 @@ class CacheSessionTests(SessionTestsMixin, unittest.TestCase): backend = CacheSession def test_load_overlong_key(self): # Some backends might issue a warning with warnings.catch_warnings(): warnings.simplefilter("ignore") @ignore_warnings(module="django.core.cache.backends.base") def test_load_overlong_key(self): self.session._session_key = (string.ascii_letters + string.digits) * 20 self.assertEqual(self.session.load(), {}) Loading
django/contrib/sitemaps/tests/test_flatpages.py +4 −4 Original line number Diff line number Diff line Loading @@ -6,13 +6,15 @@ import warnings from django.apps import apps from django.conf import settings from django.contrib.sitemaps import FlatPageSitemap from django.test import SimpleTestCase from django.test import SimpleTestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango19Warning from .base import SitemapTestsBase class FlatpagesSitemapTests(SitemapTestsBase): @ignore_warnings(category=RemovedInDjango19Warning) @skipUnless(apps.is_installed('django.contrib.flatpages'), "django.contrib.flatpages app not installed.") def test_flatpage_sitemap(self): Loading @@ -38,8 +40,6 @@ class FlatpagesSitemapTests(SitemapTestsBase): registration_required=True ) private.sites.add(settings.SITE_ID) with warnings.catch_warnings(): warnings.simplefilter('ignore') response = self.client.get('/flatpages/sitemap.xml') # Public flatpage should be in the sitemap self.assertContains(response, '<loc>%s%s</loc>' % (self.base_url, public.url)) Loading
django/contrib/sitemaps/tests/test_http.py +25 −29 Original line number Diff line number Diff line Loading @@ -3,14 +3,13 @@ from __future__ import unicode_literals import os from datetime import date from unittest import skipUnless import warnings from django.apps import apps from django.conf import settings from django.contrib.sitemaps import Sitemap, GenericSitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import modify_settings, override_settings from django.test import ignore_warnings, modify_settings, override_settings from django.utils.deprecation import RemovedInDjango20Warning from django.utils.formats import localize from django.utils._os import upath Loading @@ -21,10 +20,9 @@ from .base import TestModel, SitemapTestsBase class HTTPSitemapTests(SitemapTestsBase): @ignore_warnings(category=RemovedInDjango20Warning) def test_simple_sitemap_index(self): "A simple sitemap index can be rendered" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading @@ -39,14 +37,13 @@ class HTTPSitemapTests(SitemapTestsBase): """ % self.base_url self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @ignore_warnings(category=RemovedInDjango20Warning) @override_settings(TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')], }]) def test_simple_sitemap_custom_index(self): "A simple sitemap index can be rendered with a custom template" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading Loading @@ -196,9 +193,8 @@ class HTTPSitemapTests(SitemapTestsBase): """ % self.base_url self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @ignore_warnings(category=RemovedInDjango20Warning) def test_x_robots_sitemap(self): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving Loading