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_java_application.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_java_application.py')
-rw-r--r-- | test/test_java_application.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/test/test_java_application.py b/test/test_java_application.py index b825d925..6ff556a8 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -24,9 +24,9 @@ class TestJavaApplication(TestApplicationJava): "app": { "type": self.get_application_type(), "processes": 1, - "working_directory": option.test_dir + "/java/empty", - "webapp": temp_dir + "/java", - "unit_jars": temp_dir + "/no_such_dir", + "working_directory": f"{option.test_dir}/java/empty", + "webapp": f"{temp_dir}/java", + "unit_jars": f"{temp_dir}/no_such_dir", } }, } @@ -36,7 +36,7 @@ class TestJavaApplication(TestApplicationJava): self.load('empty_war') assert 'success' in self.conf( - '"' + temp_dir + '/java/empty.war"', + f'"{temp_dir}/java/empty.war"', '/config/applications/empty_war/webapp', ), 'configure war' @@ -118,7 +118,7 @@ class TestJavaApplication(TestApplicationJava): headers = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', }, url='/?var1=val2', @@ -157,7 +157,7 @@ class TestJavaApplication(TestApplicationJava): resp = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', } ) @@ -171,7 +171,7 @@ class TestJavaApplication(TestApplicationJava): resp = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', } ) @@ -183,7 +183,7 @@ class TestJavaApplication(TestApplicationJava): resp = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', } ) @@ -207,7 +207,7 @@ class TestJavaApplication(TestApplicationJava): resp = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', } ) @@ -223,7 +223,7 @@ class TestJavaApplication(TestApplicationJava): resp = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', } ) @@ -244,7 +244,7 @@ class TestJavaApplication(TestApplicationJava): headers = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', }, url='/?var1=val2', @@ -256,7 +256,7 @@ class TestJavaApplication(TestApplicationJava): headers = self.get( headers={ 'Host': 'localhost', - 'Cookie': 'JSESSIONID=' + session_id, + 'Cookie': f'JSESSIONID={session_id}', 'Connection': 'close', }, url='/', @@ -770,7 +770,7 @@ class TestJavaApplication(TestApplicationJava): assert headers['X-Path-Info'] == '/test', 'the rest of the path' assert ( headers['X-Path-Translated'] - == headers['X-Real-Path'] + headers['X-Path-Info'] + == f"{headers['X-Real-Path']}{headers['X-Path-Info']}" ), 'translated path is the app root + path info' assert ( headers['X-Resource-Paths'].endswith('/WEB-INF/, /index.html]') @@ -956,7 +956,7 @@ class TestJavaApplication(TestApplicationJava): self.load('multipart') reldst = '/uploads' - fulldst = temp_dir + reldst + fulldst = f'{temp_dir}{reldst}' os.mkdir(fulldst) public_dir(fulldst) @@ -989,7 +989,7 @@ class TestJavaApplication(TestApplicationJava): assert re.search(r'sample\.txt created', resp['body']), 'multipart body' assert ( self.search_in_log( - r'^Data from sample file$', name=reldst + '/sample.txt' + r'^Data from sample file$', name=f'{reldst}/sample.txt' ) is not None ), 'file created' |