summaryrefslogtreecommitdiffhomepage
path: root/test/test_proxy_chunked.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2023-02-21 17:21:29 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2023-02-21 17:21:29 +0000
commit7934dcabbc3c2b585e8d3f8fcee7020ba26f1687 (patch)
treebd0861e7832c14d92dd0ed9753932e58a2daf818 /test/test_proxy_chunked.py
parentfcabbf09d85397e244f6486d6eca25e2366b61cd (diff)
downloadunit-7934dcabbc3c2b585e8d3f8fcee7020ba26f1687.tar.gz
unit-7934dcabbc3c2b585e8d3f8fcee7020ba26f1687.tar.bz2
Tests: switched to using f-strings.
Previously, it was necessary to support older versions of Python for compatibility. F-strings were released in Python 3.6. Python 3.5 was marked as unsupported by the end of 2020, so now it's possible to start using f-strings safely for better readability and performance.
Diffstat (limited to 'test/test_proxy_chunked.py')
-rw-r--r--test/test_proxy_chunked.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/test_proxy_chunked.py b/test/test_proxy_chunked.py
index f024eaf5..f31c976a 100644
--- a/test/test_proxy_chunked.py
+++ b/test/test_proxy_chunked.py
@@ -61,7 +61,7 @@ class TestProxyChunked(TestApplicationPython):
else:
add = line
- req = req + add + '\r\n'
+ req = f'{req}{add}\r\n'
for chunk in re.split(r'([@#])', req):
if chunk == '@' or chunk == '#':
@@ -77,9 +77,9 @@ class TestProxyChunked(TestApplicationPython):
body = '\r\n\r\n'
for l, c in chunks:
- body = body + l + '\r\n' + c + '\r\n'
+ body = f'{body}{l}\r\n{c}\r\n'
- return body + '0\r\n\r\n'
+ return f'{body}0\r\n\r\n'
def get_http10(self, *args, **kwargs):
return self.get(*args, http_10=True, **kwargs)
@@ -96,7 +96,7 @@ class TestProxyChunked(TestApplicationPython):
"routes": [
{
"action": {
- "proxy": "http://127.0.0.1:" + str(self.SERVER_PORT)
+ "proxy": f'http://127.0.0.1:{self.SERVER_PORT}'
}
}
],
@@ -111,20 +111,20 @@ class TestProxyChunked(TestApplicationPython):
part = '0123456789abcdef'
assert (
- self.get_http10(body=self.chunks([('1000', part + ' X 256')]))[
+ self.get_http10(body=self.chunks([('1000', f'{part} X 256')]))[
'body'
]
== part * 256
)
assert (
- self.get_http10(body=self.chunks([('100000', part + ' X 65536')]))[
+ self.get_http10(body=self.chunks([('100000', f'{part} X 65536')]))[
'body'
]
== part * 65536
)
assert (
self.get_http10(
- body=self.chunks([('1000000', part + ' X 1048576')]),
+ body=self.chunks([('1000000', f'{part} X 1048576')]),
read_buffer_size=4096 * 4096,
)['body']
== part * 1048576
@@ -133,7 +133,7 @@ class TestProxyChunked(TestApplicationPython):
assert (
self.get_http10(
body=self.chunks(
- [('1000', part + ' X 256'), ('1000', part + ' X 256')]
+ [('1000', f'{part} X 256'), ('1000', f'{part} X 256')]
)
)['body']
== part * 256 * 2
@@ -142,8 +142,8 @@ class TestProxyChunked(TestApplicationPython):
self.get_http10(
body=self.chunks(
[
- ('100000', part + ' X 65536'),
- ('100000', part + ' X 65536'),
+ ('100000', f'{part} X 65536'),
+ ('100000', f'{part} X 65536'),
]
)
)['body']
@@ -153,8 +153,8 @@ class TestProxyChunked(TestApplicationPython):
self.get_http10(
body=self.chunks(
[
- ('1000000', part + ' X 1048576'),
- ('1000000', part + ' X 1048576'),
+ ('1000000', f'{part} X 1048576'),
+ ('1000000', f'{part} X 1048576'),
]
),
read_buffer_size=4096 * 4096,