@@ -1020,31 +1020,6 @@ def tearDownClass(cls):
10201020 super ().tearDownClass ()
10211021 conf .settings = conf .LazySettings ()
10221022
1023- @staticmethod
1024- def _format_request_objects_in_headers (attributes ):
1025- for key , value_list in list (attributes .items ()):
1026- new_values = []
1027- for value in value_list :
1028- if hasattr (value , "__class__" ):
1029- if value .__class__ .__name__ in (
1030- "HttpRequest" ,
1031- "WSGIRequest" ,
1032- ):
1033- try :
1034- method = getattr (value , "method" , "UNKNOWN" )
1035- request_path = getattr (value , "path" , "UNKNOWN" )
1036- new_values .append (
1037- f"HttpRequest({ method } { request_path } )"
1038- )
1039- except (AttributeError , ValueError , TypeError ):
1040- new_values .append ("HttpRequest(...)" )
1041- else :
1042- new_values .append (value )
1043- else :
1044- new_values .append (value )
1045- attributes [key ] = new_values
1046- return attributes
1047-
10481023 def test_wsgi_request_in_header_is_properly_formatted (self ):
10491024 mock_wsgi_request = Mock (spec = WSGIRequest )
10501025 mock_wsgi_request .method = "GET"
@@ -1060,7 +1035,7 @@ def test_wsgi_request_in_header_is_properly_formatted(self):
10601035 ]
10611036 }
10621037
1063- formatted_attributes = TestMiddlewareWsgiWithCustomHeaders . _format_request_objects_in_headers (
1038+ formatted_attributes = _DjangoMiddleware . format_request_objects_in_headers (
10641039 input_attributes
10651040 )
10661041
@@ -1081,7 +1056,7 @@ def test_wsgi_request_handles_extraction_error(self):
10811056 "http.request.header.test_wsgirequest_header" : ["HttpRequest(...)" ]
10821057 }
10831058
1084- formatted_attributes = TestMiddlewareWsgiWithCustomHeaders . _format_request_objects_in_headers (
1059+ formatted_attributes = _DjangoMiddleware . format_request_objects_in_headers (
10851060 input_attributes
10861061 )
10871062
@@ -1102,7 +1077,7 @@ def test_handles_http_request_as_well(self):
11021077 ]
11031078 }
11041079
1105- formatted_attributes = TestMiddlewareWsgiWithCustomHeaders . _format_request_objects_in_headers (
1080+ formatted_attributes = _DjangoMiddleware . format_request_objects_in_headers (
11061081 input_attributes
11071082 )
11081083
@@ -1125,7 +1100,7 @@ def test_regular_header_values_are_preserved(self):
11251100 "http.request.header.test_regular_header" : ["regular-value" ],
11261101 }
11271102
1128- formatted_attributes = TestMiddlewareWsgiWithCustomHeaders . _format_request_objects_in_headers (
1103+ formatted_attributes = _DjangoMiddleware . format_request_objects_in_headers (
11291104 input_attributes
11301105 )
11311106
0 commit comments