From fe089902e1532a2631c9b83d79b22591f9c463d4 Mon Sep 17 00:00:00 2001 From: Ben Cail Date: Mon, 18 Mar 2024 15:10:50 -0400 Subject: [PATCH] linters --- tests/requests_tests/tests.py | 37 ++++++++++++++---------- tests/utils_tests/test_datastructures.py | 14 ++++----- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/tests/requests_tests/tests.py b/tests/requests_tests/tests.py index cb987796d2..8238ca5a68 100644 --- a/tests/requests_tests/tests.py +++ b/tests/requests_tests/tests.py @@ -1053,21 +1053,28 @@ class RequestsTests(SimpleTestCase): """ MultiPartParser.parse() leaves request.FILES immutable. """ - payload = FakePayload("\r\n".join([ - '--boundary', - 'Content-Disposition: form-data; name="upload_file"; filename="asd.txt"', - 'Content-Type: text/plain', - '', - 'asd', - '--boundary--', - ])) - request = WSGIRequest({ - 'REQUEST_METHOD': 'POST', - 'CONTENT_TYPE': 'multipart/form-data; boundary=boundary', - 'CONTENT_LENGTH': len(payload), - 'wsgi.input': payload, - }) - self.assertTrue('upload_file' in request.FILES) + content_disposition = 'form-data; name="upload_file"; filename="asd.txt"' + payload = FakePayload( + "\r\n".join( + [ + "--boundary", + f"Content-Disposition: {content_disposition}", + "Content-Type: text/plain", + "", + "asd", + "--boundary--", + ] + ) + ) + request = WSGIRequest( + { + "REQUEST_METHOD": "POST", + "CONTENT_TYPE": "multipart/form-data; boundary=boundary", + "CONTENT_LENGTH": len(payload), + "wsgi.input": payload, + } + ) + self.assertTrue("upload_file" in request.FILES) self.assertFalse(request.FILES._mutable) def test_FILES_connection_error(self): diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py index 957e1a8f4d..cca8c5512c 100644 --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -253,15 +253,15 @@ class ImmutableMultiValueDictTests(SimpleTestCase): def test_immutability(self): q = MultiValueDict(mutable=False) with self.assertRaises(AttributeError): - q.__setitem__('something', 'bar') + q.__setitem__("something", "bar") with self.assertRaises(AttributeError): - q.setlist('foo', ['bar']) + q.setlist("foo", ["bar"]) with self.assertRaises(AttributeError): - q.appendlist('foo', ['bar']) + q.appendlist("foo", ["bar"]) with self.assertRaises(AttributeError): - q.update({'foo': 'bar'}) + q.update({"foo": "bar"}) with self.assertRaises(AttributeError): - q.pop('foo') + q.pop("foo") with self.assertRaises(AttributeError): q.popitem() with self.assertRaises(AttributeError): @@ -272,8 +272,8 @@ class ImmutableMultiValueDictTests(SimpleTestCase): q = MultiValueDict(mutable=False).copy() with self.assertRaises(KeyError): q.__getitem__("foo") - q['name'] = 'john' - self.assertEqual(q['name'], 'john') + q["name"] = "john" + self.assertEqual(q["name"], "john") class ImmutableListTests(SimpleTestCase):