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_python_procman.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_python_procman.py')
-rw-r--r-- | test/test_python_procman.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/test_python_procman.py b/test/test_python_procman.py index a25b84ec..d69123ef 100644 --- a/test/test_python_procman.py +++ b/test/test_python_procman.py @@ -12,8 +12,8 @@ class TestPythonProcman(TestApplicationPython): prerequisites = {'modules': {'python': 'any'}} def setup_method(self): - self.app_name = "app-" + option.temp_dir.split('/')[-1] - self.app_proc = 'applications/' + self.app_name + '/processes' + self.app_name = f'app-{option.temp_dir.split("/")[-1]}' + self.app_proc = f'applications/{self.app_name}/processes' self.load('empty', self.app_name) def pids_for_process(self): @@ -23,7 +23,7 @@ class TestPythonProcman(TestApplicationPython): pids = set() for m in re.findall( - '.*unit: "' + self.app_name + '" application', output.decode() + fr'.*unit: "{self.app_name}" application', output.decode() ): pids.add(re.search(r'^\s*(\d+)', m).group(1)) @@ -126,7 +126,7 @@ class TestPythonProcman(TestApplicationPython): assert len(pids_new) == 3, 'reconf 3' assert pids.issubset(pids_new), 'reconf 3 only 1 new' - self.conf_proc('6', self.app_proc + '/spare') + self.conf_proc('6', f'{self.app_proc}/spare') pids = self.pids_for_process() assert len(pids) == 6, 'reconf 6' @@ -176,10 +176,10 @@ class TestPythonProcman(TestApplicationPython): def test_python_processes_access(self): self.conf_proc('1') - path = '/' + self.app_proc - assert 'error' in self.conf_get(path + '/max') - assert 'error' in self.conf_get(path + '/spare') - assert 'error' in self.conf_get(path + '/idle_timeout') + path = f'/{self.app_proc}' + assert 'error' in self.conf_get(f'{path}/max') + assert 'error' in self.conf_get(f'{path}/spare') + assert 'error' in self.conf_get(f'{path}/idle_timeout') def test_python_processes_invalid(self): assert 'error' in self.conf( @@ -206,7 +206,7 @@ class TestPythonProcman(TestApplicationPython): def test_python_restart(self, temp_dir): shutil.copyfile( - option.test_dir + '/python/restart/v1.py', temp_dir + '/wsgi.py' + f'{option.test_dir}/python/restart/v1.py', f'{temp_dir}/wsgi.py' ) self.load( @@ -220,14 +220,14 @@ class TestPythonProcman(TestApplicationPython): assert b == "v1", 'process started' shutil.copyfile( - option.test_dir + '/python/restart/v2.py', temp_dir + '/wsgi.py' + f'{option.test_dir}/python/restart/v2.py', f'{temp_dir}/wsgi.py' ) b = self.get()['body'] assert b == "v1", 'still old process' assert 'success' in self.conf_get( - '/control/applications/' + self.app_name + '/restart' + f'/control/applications/{self.app_name}/restart' ), 'restart processes' b = self.get()['body'] @@ -238,7 +238,7 @@ class TestPythonProcman(TestApplicationPython): ), 'application incorrect' assert 'error' in self.conf_delete( - '/control/applications/' + self.app_name + '/restart' + f'/control/applications/{self.app_name}/restart' ), 'method incorrect' def test_python_restart_multi(self): @@ -248,7 +248,7 @@ class TestPythonProcman(TestApplicationPython): assert len(pids) == 2, 'restart 2 started' assert 'success' in self.conf_get( - '/control/applications/' + self.app_name + '/restart' + f'/control/applications/{self.app_name}/restart' ), 'restart processes' new_pids = self.pids_for_process() @@ -272,7 +272,7 @@ class TestPythonProcman(TestApplicationPython): assert len(pids) == 2, 'longstarts == 2' assert 'success' in self.conf_get( - '/control/applications/' + self.app_name + '/restart' + f'/control/applications/{self.app_name}/restart' ), 'restart processes' # wait for longstarted app |