diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2023-02-21 17:21:29 +0000 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2023-02-21 17:21:29 +0000 |
commit | 7934dcabbc3c2b585e8d3f8fcee7020ba26f1687 (patch) | |
tree | bd0861e7832c14d92dd0ed9753932e58a2daf818 /test/test_access_log.py | |
parent | fcabbf09d85397e244f6486d6eca25e2366b61cd (diff) | |
download | unit-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_access_log.py')
-rw-r--r-- | test/test_access_log.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/test/test_access_log.py b/test/test_access_log.py index a072858b..ffaae0b1 100644 --- a/test/test_access_log.py +++ b/test/test_access_log.py @@ -12,13 +12,13 @@ class TestAccessLog(TestApplicationPython): super().load(script) assert 'success' in self.conf( - '"' + option.temp_dir + '/access.log"', 'access_log' + f'"{option.temp_dir}/access.log"', 'access_log' ), 'access_log configure' def set_format(self, format): assert 'success' in self.conf( { - 'path': option.temp_dir + '/access.log', + 'path': f'{option.temp_dir}/access.log', 'format': format, }, 'access_log', @@ -103,13 +103,13 @@ Connection: close is not None ), 'ipv6' - def test_access_log_unix(self): + def test_access_log_unix(self, temp_dir): self.load('empty') - addr = option.temp_dir + '/sock' + addr = f'{temp_dir}/sock' assert 'success' in self.conf( - {"unix:" + addr: {"pass": "applications/empty"}}, 'listeners' + {f'unix:{addr}': {"pass": "applications/empty"}}, 'listeners' ) self.get(sock_type='unix', addr=addr) @@ -248,14 +248,12 @@ Connection: close assert self.search_in_log(r'/delete', 'access.log') is None, 'delete' - def test_access_log_change(self): + def test_access_log_change(self, temp_dir): self.load('empty') self.get() - assert 'success' in self.conf( - '"' + option.temp_dir + '/new.log"', 'access_log' - ) + assert 'success' in self.conf(f'"{temp_dir}/new.log"', 'access_log') self.get() @@ -286,19 +284,20 @@ Connection: close body = '0123456789' * 50 self.post(url='/bbs', body=body, read_timeout=1) assert ( - self.wait_for_record(r'^\/bbs ' + str(len(body)) + r'$') is not None + self.wait_for_record(fr'^\/bbs {len(body)}$') is not None ), '$body_bytes_sent' - def test_access_log_incorrect(self, skip_alert): + def test_access_log_incorrect(self, temp_dir, skip_alert): skip_alert(r'failed to apply new conf') assert 'error' in self.conf( - option.temp_dir + '/blah/access.log' 'access_log/path', + f'{option.temp_dir}/blah/access.log', + 'access_log/path', ), 'access_log path incorrect' assert 'error' in self.conf( { - 'path': option.temp_dir + '/access.log', + 'path': f'{temp_dir}/access.log', 'format': '$remote_add', }, 'access_log', |