Skip to content

Commit 97ff354

Browse files
committed
Replace f-strings with format for py35 compatability
1 parent f7d74ea commit 97ff354

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

rest_framework/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
self.exception = exception
5050
self.content_type = content_type
5151
if reason:
52-
self.reason_phrase = f"{self.status_text} ({reason})"
52+
self.reason_phrase = "{} ({})".format(self.status_text, reason)
5353

5454
if headers:
5555
for name, value in headers.items():

tests/test_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def test_form_has_label_and_help_text(self):
297297
class ReasonPhraseTests(TestCase):
298298
def test_reason_is_set(self):
299299
resp = self.client.get('/with_reason')
300-
self.assertEqual(f"OK ({DUMMYREASON})", resp.reason_phrase)
300+
self.assertEqual("OK ({})".format(DUMMYREASON), resp.reason_phrase)
301301

302302
def test_reason_phrase_with_no_reason(self):
303303
resp = self.client.get('/')

tests/test_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_400_validation_error(self):
9999
request = factory.get('/')
100100
response = ValidationErrorView.as_view()(request)
101101
assert response.status_code == status.HTTP_400_BAD_REQUEST
102-
assert response.reason_phrase == f"{STATUS_CODE_400} ({VALIDATION_ERROR})"
102+
assert response.reason_phrase == "{} ({})".format(STATUS_CODE_400, VALIDATION_ERROR)
103103
assert response.data == [VALIDATION_ERROR]
104104

105105

@@ -119,7 +119,7 @@ def test_400_validation_error(self):
119119
request = factory.get('/')
120120
response = validation_error_view(request)
121121
assert response.status_code == status.HTTP_400_BAD_REQUEST
122-
assert response.reason_phrase == f"{STATUS_CODE_400} ({VALIDATION_ERROR})"
122+
assert response.reason_phrase == "{} ({})".format(STATUS_CODE_400, VALIDATION_ERROR)
123123
assert response.data == [VALIDATION_ERROR]
124124

125125

0 commit comments

Comments
 (0)