132 lines
5.1 KiB
Diff
132 lines
5.1 KiB
Diff
From 8abebb36b1ec64b1e1228634e42381c0f592fdd4 Mon Sep 17 00:00:00 2001
|
|
From: Luke Pomfrey <luke@lukepomfrey.org>
|
|
Date: Tue, 4 Jan 2022 13:57:51 +0000
|
|
Subject: [PATCH] Fixes for django 4.0
|
|
|
|
Origin:
|
|
https://github.com/lpomfrey/django-debreach/commit/8abebb36b1ec64b1e1228634e42381c0f592fdd4
|
|
---
|
|
debreach/tests.py | 12 ++++++------
|
|
setup.py | 2 ++
|
|
test_project/urls.py | 18 +++++++-----------
|
|
3 files changed, 15 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/debreach/tests.py b/debreach/tests.py
|
|
index 70eedb0..4626e7d 100644
|
|
--- a/debreach/tests.py
|
|
+++ b/debreach/tests.py
|
|
@@ -21,7 +21,7 @@ class TestRandomCommentMiddleware(TestCase):
|
|
def test_noop_on_wrong_content_type(self):
|
|
response = HttpResponse('abc', content_type='text/plain')
|
|
request = RequestFactory().get('/')
|
|
- middleware = RandomCommentMiddleware()
|
|
+ middleware = RandomCommentMiddleware(lambda request: response)
|
|
response = middleware.process_response(request, response)
|
|
self.assertEqual(response.content, b'abc')
|
|
|
|
@@ -38,7 +38,7 @@ class TestRandomCommentMiddleware(TestCase):
|
|
</html>'''
|
|
response = HttpResponse(html, content_type='text/html')
|
|
request = RequestFactory().get('/')
|
|
- middleware = RandomCommentMiddleware()
|
|
+ middleware = RandomCommentMiddleware(lambda request: response)
|
|
response = middleware.process_response(request, response)
|
|
self.assertNotEqual(response.content, html)
|
|
|
|
@@ -55,7 +55,7 @@ class TestRandomCommentMiddleware(TestCase):
|
|
</html>'''.format(''.join(chr(x) for x in range(9999)))
|
|
response = HttpResponse(html, content_type='text/html')
|
|
request = RequestFactory().get('/')
|
|
- middleware = RandomCommentMiddleware()
|
|
+ middleware = RandomCommentMiddleware(lambda request: response)
|
|
response = middleware.process_response(request, response)
|
|
self.assertNotEqual(force_str(response.content), force_str(html))
|
|
|
|
@@ -67,7 +67,7 @@ class TestRandomCommentMiddleware(TestCase):
|
|
response = HttpResponse(html)
|
|
response._random_comment_exempt = True
|
|
request = RequestFactory().get('/')
|
|
- middleware = RandomCommentMiddleware()
|
|
+ middleware = RandomCommentMiddleware(lambda request: response)
|
|
response = middleware.process_response(request, response)
|
|
self.assertEqual(force_str(response.content), html)
|
|
|
|
@@ -75,14 +75,14 @@ class TestRandomCommentMiddleware(TestCase):
|
|
request = RequestFactory().get('/')
|
|
response = HttpResponse('')
|
|
del response['Content-Type']
|
|
- middleware = RandomCommentMiddleware()
|
|
+ middleware = RandomCommentMiddleware(lambda request: response)
|
|
processed_response = middleware.process_response(request, response)
|
|
self.assertEqual(response, processed_response)
|
|
|
|
def test_empty_response_body_ignored(self):
|
|
request = RequestFactory().get('/')
|
|
response = HttpResponse('')
|
|
- middleware = RandomCommentMiddleware()
|
|
+ middleware = RandomCommentMiddleware(lambda request: response)
|
|
processed_response = middleware.process_response(request, response)
|
|
self.assertEqual(len(processed_response.content), 0)
|
|
|
|
diff --git a/setup.py b/setup.py
|
|
index 850b52b..7c54d1b 100644
|
|
--- a/setup.py
|
|
+++ b/setup.py
|
|
@@ -68,6 +68,8 @@ setup(
|
|
'Operating System :: OS Independent',
|
|
'Framework :: Django',
|
|
'Framework :: Django :: 2.2',
|
|
+ 'Framework :: Django :: 3.2',
|
|
+ 'Framework :: Django :: 4.0',
|
|
'Programming Language :: Python',
|
|
'Programming Language :: Python :: 3',
|
|
'Programming Language :: Python :: 3.5',
|
|
diff --git a/test_project/urls.py b/test_project/urls.py
|
|
index d74ec85..cf2a802 100644
|
|
--- a/test_project/urls.py
|
|
+++ b/test_project/urls.py
|
|
@@ -1,13 +1,12 @@
|
|
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
-from django.conf.urls import url
|
|
+from django.urls import re_path
|
|
from django.views.generic.base import TemplateView
|
|
from django.views.generic.edit import FormView
|
|
|
|
from test_project.forms import TestForm
|
|
|
|
-
|
|
# Uncomment the next two lines to enable the admin:
|
|
# from django.contrib import admin
|
|
# admin.autodiscover()
|
|
@@ -16,19 +15,16 @@ urlpatterns = [
|
|
# Examples:
|
|
# url(r'^$', 'test_project.views.home', name='home'),
|
|
# url(r'^test_project/', include('test_project.foo.urls')),
|
|
-
|
|
# Uncomment the admin/doc line below to enable admin documentation:
|
|
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
|
-
|
|
# Uncomment the next line to enable the admin:
|
|
# url(r'^admin/', include(admin.site.urls)),
|
|
- url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'),
|
|
- url(
|
|
- r'^form/$',
|
|
+ re_path(r"^$", TemplateView.as_view(template_name="home.html"), name="home"),
|
|
+ re_path(
|
|
+ r"^form/$",
|
|
FormView.as_view(
|
|
- form_class=TestForm,
|
|
- template_name='test.html',
|
|
- success_url='/'),
|
|
- name='test_form'
|
|
+ form_class=TestForm, template_name="test.html", success_url="/"
|
|
+ ),
|
|
+ name="test_form",
|
|
),
|
|
]
|
|
--
|
|
2.33.0
|
|
|