From 7934dcabbc3c2b585e8d3f8fcee7020ba26f1687 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 21 Feb 2023 17:21:29 +0000 Subject: 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. --- test/test_static_fallback.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'test/test_static_fallback.py') diff --git a/test/test_static_fallback.py b/test/test_static_fallback.py index 1f1a1df7..75012bbb 100644 --- a/test/test_static_fallback.py +++ b/test/test_static_fallback.py @@ -10,11 +10,12 @@ class TestStaticFallback(TestApplicationProto): @pytest.fixture(autouse=True) def setup_method_fixture(self, temp_dir): - os.makedirs(temp_dir + '/assets/dir') - Path(temp_dir + '/assets/index.html').write_text('0123456789') + assets_dir = f'{temp_dir}/assets' + os.makedirs(f'{assets_dir}/dir') + Path(f'{assets_dir}/index.html').write_text('0123456789') - os.makedirs(temp_dir + '/assets/403') - os.chmod(temp_dir + '/assets/403', 0o000) + os.makedirs(f'{assets_dir}/403') + os.chmod(f'{assets_dir}/403', 0o000) self._load_conf( { @@ -22,7 +23,7 @@ class TestStaticFallback(TestApplicationProto): "*:7080": {"pass": "routes"}, "*:7081": {"pass": "routes"}, }, - "routes": [{"action": {"share": temp_dir + "/assets$uri"}}], + "routes": [{"action": {"share": f'{assets_dir}$uri'}}], "applications": {}, } ) @@ -30,7 +31,7 @@ class TestStaticFallback(TestApplicationProto): yield try: - os.chmod(temp_dir + '/assets/403', 0o777) + os.chmod(f'{assets_dir}/403', 0o777) except FileNotFoundError: pass @@ -49,7 +50,7 @@ class TestStaticFallback(TestApplicationProto): def test_static_fallback_valid_path(self, temp_dir): self.action_update( - {"share": temp_dir + "/assets$uri", "fallback": {"return": 200}} + {"share": f"{temp_dir}/assets$uri", "fallback": {"return": 200}} ) resp = self.get() assert resp['status'] == 200, 'fallback status' @@ -84,7 +85,7 @@ class TestStaticFallback(TestApplicationProto): self.action_update( { "share": "/blah", - "fallback": {"share": temp_dir + "/assets$uri"}, + "fallback": {"share": f"{temp_dir}/assets$uri"}, } ) -- cgit