summaryrefslogtreecommitdiffhomepage
path: root/test/test_static_fallback.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_static_fallback.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_static_fallback.py')
-rw-r--r--test/test_static_fallback.py17
1 files changed, 9 insertions, 8 deletions
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"},
}
)