Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings #5680

Merged
merged 43 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
958f432
Add Django 2.0 support to jobmanager tests
cwdavies Apr 22, 2020
c13ea5d
Merge branch 'master' into job-django20
cwdavies Apr 22, 2020
6e9f192
Update django reverse
cwdavies Apr 22, 2020
51dfbaa
Remove Django 1.10 deprecations
cwdavies Apr 22, 2020
050caca
Fix DeprecationWarning: Please use assertEqual instead.
cwdavies Apr 22, 2020
35cc759
Fix DeprecationWarning: Please use assertRaisesRegex instead.
cwdavies Apr 22, 2020
3da8920
Fix DeprecationWarning: The modelcluster.tags module has been moved t…
cwdavies Apr 22, 2020
d6a186d
Fix DeprecationWarning: the imp module is deprecated in favour of imp…
cwdavies Apr 22, 2020
7f5b562
Fix DeprecationWarning: The unescape method is deprecated and will be…
cwdavies Apr 22, 2020
6ab00f1
Fix AttributeError: module 'django.utils.html' has no attribute 'unes…
cwdavies Apr 22, 2020
660490f
Fix NameError: name 'HTMLParser' is not defined
cwdavies Apr 22, 2020
57a9de3
Fix NameError: name 'HTMLParser' is not defined
cwdavies Apr 22, 2020
18435ca
Fix AttributeError: 'str' object has no attribute 'parser'
cwdavies Apr 22, 2020
19efa3b
Fix AttributeError: module 'html' has no attribute 'strip_tags'
cwdavies Apr 22, 2020
77f1b68
Fix DeprecationWarning: The 'warn' method is deprecated, use 'warning…
cwdavies Apr 22, 2020
9280e30
Fix DeprecationWarning: Please use assertRegex instead.
cwdavies Apr 22, 2020
5988bb5
Fix DeprecationWarning with unescaped
cwdavies Apr 22, 2020
e2b00b2
Fix DeprecationWarning relating to html.parser
cwdavies Apr 22, 2020
3cb3192
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 22, 2020
d68e4b3
Fix Imports are incorrectly sorted error
cwdavies Apr 22, 2020
63cbe44
Remove Django 1.10 imports
cwdavies Apr 22, 2020
1f9f7d5
Remove Django 1.10 imports for re_path
cwdavies Apr 22, 2020
2b27676
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 23, 2020
4e42a45
Add Django 1.11 imports for re_path
cwdavies Apr 23, 2020
c5053bb
Fix DeprecationWarning raised by django/urls/resolvers.py
cwdavies Apr 23, 2020
502078b
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 24, 2020
c21aa68
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 24, 2020
5a76dc0
Add test_handle_404_error
cwdavies Apr 27, 2020
311bbf4
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 27, 2020
283ca52
Update HandleErrorTestCase
cwdavies Apr 27, 2020
55972f8
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 27, 2020
99d7f79
Add unit test for SimpleUploadedFile
cwdavies Apr 27, 2020
3fe1bce
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 28, 2020
e21e3d1
Update ntplib from 0.3.3 to 0.3.4
cwdavies Apr 28, 2020
ecfa088
Add Django 2.2 support to login_with_lockout for v1.tests.views.test_…
cwdavies Apr 29, 2020
6114409
Merge branch 'master' into fix-deprecation-warnings
cwdavies Apr 30, 2020
7963511
Add test_handle_404_error_case_insensitive_redirect
cwdavies Apr 30, 2020
134528d
Made redirect permanent and added HttpResponsePermanentRedirect
cwdavies Apr 30, 2020
abc6b22
Add Django 2.2 support to v1 admin forms and views for v1.tests.test_…
cwdavies Apr 30, 2020
4dec00d
Fix TypeError: Cannot encode None as POST data
cwdavies Apr 30, 2020
73d6c17
Add assertEqual to test_handle_404_error_case_insensitive_redirect
cwdavies May 1, 2020
69ed441
Assert that we get redirected to lower case
willbarton May 1, 2020
7a3aa30
Merge branch 'master' into fix-deprecation-warnings
cwdavies May 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions cfgov/agreements/tests/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
from django.core.paginator import Page
from django.http import HttpResponse
from django.test import TestCase
from django.urls import reverse

from mock import patch

from agreements import models


try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse


def agreement_factory(**kwargs):
"""
Create an agreement with some defaults.
Expand Down
7 changes: 1 addition & 6 deletions cfgov/agreements/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
from django.http import Http404
from django.test import RequestFactory, TestCase
from django.urls import reverse

from agreements.models import Agreement, Issuer
from agreements.views import issuer_search


try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse


class TestIssuerSearch(TestCase):
def setUp(self):
self.request = RequestFactory().get("/")
Expand Down
15 changes: 6 additions & 9 deletions cfgov/agreements/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from agreements.views import index, issuer_search

from django.urls import re_path

try:
from django.urls import re_path
except ImportError:
from django.conf.urls import url as re_path
cwdavies marked this conversation as resolved.
Show resolved Hide resolved
from agreements.views import index, issuer_search


urlpatterns = [
re_path(r'^$', index, name='agreements_home'),
re_path(r'^issuer/(?P<issuer_slug>.*)/$', issuer_search,
name='issuer_search'),
re_path(r"^$", index, name="agreements_home"),
re_path(
r"^issuer/(?P<issuer_slug>.*)/$", issuer_search, name="issuer_search"
),
]
4 changes: 0 additions & 4 deletions cfgov/ask_cfpb/models/django.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
import html.parser as HTMLParser

from django.contrib.auth.models import User
from django.db import models

Expand All @@ -9,8 +7,6 @@
from wagtail.images.edit_handlers import ImageChooserPanel


html_parser = HTMLParser.HTMLParser()

ENGLISH_PARENT_SLUG = 'ask-cfpb'
SPANISH_PARENT_SLUG = 'obtener-respuestas'

Expand Down
10 changes: 4 additions & 6 deletions cfgov/ask_cfpb/scripts/export_ask_data.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import datetime
import html.parser as HTMLParser
import html

from django.http import HttpResponse
from django.utils import html
from django.utils import html as html_util

import unicodecsv

from ask_cfpb.models.pages import AnswerPage


html_parser = HTMLParser.HTMLParser()

HEADINGS = [
'ASK_ID',
'PAGE_ID',
Expand All @@ -29,8 +27,8 @@


def clean_and_strip(data):
unescaped = html_parser.unescape(data)
return html.strip_tags(unescaped).strip()
unescaped = html.unescape(data)
return html_util.strip_tags(unescaped).strip()


def assemble_output():
Expand Down
9 changes: 1 addition & 8 deletions cfgov/ask_cfpb/tests/models/test_pages.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
import datetime
from html.parser import HTMLParser
from unittest import mock

from django.apps import apps
from django.contrib.auth.models import User
from django.core.paginator import Paginator
from django.http import HttpRequest, HttpResponse
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone, translation
from haystack.models import SearchResult
from haystack.query import SearchQuerySet
Expand Down Expand Up @@ -38,13 +38,6 @@
)


try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse


html_parser = HTMLParser()
now = timezone.now()


Expand Down
7 changes: 1 addition & 6 deletions cfgov/ask_cfpb/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.apps import apps
from django.http import Http404, HttpRequest, QueryDict
from django.test import TestCase, override_settings
from django.urls import NoReverseMatch, reverse
from django.utils import timezone

from wagtail.core.models import Site
Expand All @@ -21,12 +22,6 @@
from v1.util.migrations import get_or_create_page


try:
from django.urls import NoReverseMatch, reverse
except ImportError:
from django.core.urlresolvers import NoReverseMatch, reverse


now = timezone.now()


Expand Down
10 changes: 2 additions & 8 deletions cfgov/ask_cfpb/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.conf import settings
from django.shortcuts import render
from django.urls import re_path, reverse
from django.utils.html import format_html

from wagtail.admin.menu import MenuItem
Expand All @@ -10,13 +11,6 @@
from ask_cfpb.scripts import export_ask_data


try:
from django.urls import re_path, reverse
except ImportError:
from django.conf.urls import url as re_path
from django.core.urlresolvers import reverse


def export_data(request):
if request.method == 'POST':
return export_ask_data.export_questions(http_response=True)
Expand All @@ -35,7 +29,7 @@ def editor_css():
def register_export_menu_item():
return MenuItem(
'Export Ask data',
reverse('export-ask'),
reverse("export-ask"),
classnames='icon icon-download',
order=99999,
)
Expand Down
4 changes: 2 additions & 2 deletions cfgov/cfgov/tests/test_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from imp import reload
from importlib import reload

import django
from django.test import RequestFactory, TestCase, override_settings
Expand Down Expand Up @@ -90,7 +90,7 @@ def dummy_external_site_view(request):


urlpatterns = [
# Needed for rendering of base template that calls reverse('external-site')
# Needed for rendering of base template that calls reverse("external-site")
re_path(r'^external-site/$', dummy_external_site_view,
name='external-site'),

Expand Down
7 changes: 1 addition & 6 deletions cfgov/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.http import Http404, QueryDict
from django.test import RequestFactory, TestCase, override_settings
from django.urls import reverse

from mock import Mock, patch
from requests_toolbelt.multipart.encoder import MultipartEncoder
Expand All @@ -15,12 +16,6 @@
)


try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse


class GovDeliverySubscribeTest(TestCase):
def setUp(self):
self.factory = RequestFactory()
Expand Down
4 changes: 2 additions & 2 deletions cfgov/core/tests/testutils/test_mock_staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_filesystem_finder_finds_test_file(self):

This test serves as a baseline to demonstrate default Django behavior.
"""
self.assertRegexpMatches(
self.assertRegex(
finders.find('icons/test.svg'),
'icons/test.svg$'
)
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_mock_finder_falls_back_to_filesystem_finder(self):
icons/test.svg instead. Because we have a FileSystemFinder that can
handle that redirected request, this call should succeed.
"""
self.assertRegexpMatches(
self.assertRegex(
finders.find('missing/file.svg'),
'icons/test.svg$'
)
Expand Down
11 changes: 3 additions & 8 deletions cfgov/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@

from django.core.signing import Signer
from django.template.defaultfilters import slugify
from django.urls import reverse

from bs4 import BeautifulSoup

from core.templatetags.svg_icon import svg_icon


try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse


NON_GOV_LINKS = re.compile(
r'https?:\/\/(?:www\.)?(?![^\?]+gov)(?!(content\.)?localhost).*'
)
Expand Down Expand Up @@ -66,12 +61,12 @@ def signed_redirect(url):
query_args = {'ext_url': url,
'signature': signature}

return ('{0}?{1}'.format(reverse('external-site'), urlencode(query_args)))
return ("{0}?{1}".format(reverse("external-site"), urlencode(query_args)))


def unsigned_redirect(url):
query_args = {'ext_url': url}
return ('{0}?{1}'.format(reverse('external-site'), urlencode(query_args)))
return ("{0}?{1}".format(reverse("external-site"), urlencode(query_args)))


def extract_answers_from_request(request):
Expand Down
7 changes: 1 addition & 6 deletions cfgov/data_research/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest

import django
from django.urls import NoReverseMatch, reverse

from model_bakery import baker

Expand All @@ -13,12 +14,6 @@
from data_research.views import validate_year_month


try:
from django.urls import NoReverseMatch, reverse
except ImportError:
from django.core.urlresolvers import NoReverseMatch, reverse


class YearMonthValidatorTests(unittest.TestCase):
"""check the year_month validator"""

Expand Down
24 changes: 10 additions & 14 deletions cfgov/data_research/urls.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
from django.urls import re_path

from data_research.views import (
MapData, MetaData, TimeSeriesData, TimeSeriesNational
)


try:
from django.urls import re_path
except ImportError:
from django.conf.urls import url as re_path


urlpatterns = [
re_path(
r'^time-series/(?P<days_late>[3890-]*)/(?P<fips>[0-9non-]*)/?$',
r"^time-series/(?P<days_late>[3890-]*)/(?P<fips>[0-9non-]*)/?$",
TimeSeriesData.as_view(),
name='data_research_api_mortgage_timeseries'
name="data_research_api_mortgage_timeseries",
),
re_path(
r'^time-series/(?P<days_late>[3890-]*)/national/?$',
r"^time-series/(?P<days_late>[3890-]*)/national/?$",
TimeSeriesNational.as_view(),
name='data_research_api_mortgage_timeseries_national'
name="data_research_api_mortgage_timeseries_national",
),
re_path(
r'^map-data/(?P<days_late>[3890-]*)/(?P<geo>[a-z]*)/(?P<year_month>\d{4}-\d{2})/?$', # noqa: E501
r"^map-data/(?P<days_late>[3890-]*)/(?P<geo>[a-z]*)/(?P<year_month>\d{4}-\d{2})/?$", # noqa: E501
MapData.as_view(),
name='data_research_api_mortgage_mapdata'
name="data_research_api_mortgage_mapdata",
),
re_path(
r'^metadata/(?P<meta_name>[a-z_]*)/?$',
r"^metadata/(?P<meta_name>[a-z_]*)/?$",
MetaData.as_view(),
name='data_research_api_metadata'
name="data_research_api_metadata",
),
]
7 changes: 1 addition & 6 deletions cfgov/diversity_inclusion/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from django.core import mail
from django.test import TestCase


try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from django.urls import reverse


class TestGetAssessmentForm(TestCase):
Expand Down
23 changes: 9 additions & 14 deletions cfgov/diversity_inclusion/urls.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
from django.urls import re_path
from django.views.generic import TemplateView

from diversity_inclusion.views import GetAssessmentForm


try:
from django.urls import re_path
except ImportError:
from django.conf.urls import url as re_path


urlpatterns = [
re_path(
r'^voluntary-assessment-onboarding-form/$(?i)',
r"^voluntary-assessment-onboarding-form/$(?i)",
GetAssessmentForm.as_view(),
name='voluntary_assessment_form'
name="voluntary_assessment_form",
),
re_path(
r'^voluntary-assessment-onboarding-form/form-submitted/$(?i)',
r"^voluntary-assessment-onboarding-form/form-submitted/$(?i)",
TemplateView.as_view(
template_name='diversity_inclusion/form-submitted.html'
template_name="diversity_inclusion/form-submitted.html"
),
name='form_submitted'
name="form_submitted",
),
re_path(
r'^voluntary-assessment-onboarding-form/privacy-act-statement/$(?i)',
r"^voluntary-assessment-onboarding-form/privacy-act-statement/$(?i)",
TemplateView.as_view(
template_name='diversity_inclusion/privacy.html'
template_name="diversity_inclusion/privacy.html"
),
name='privacy'
name="privacy",
),
]
Loading