summaryrefslogtreecommitdiffhomepage
path: root/test/test_static_symlink.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_symlink.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 '')
-rw-r--r--test/test_static_symlink.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/test_static_symlink.py b/test/test_static_symlink.py
index 24638e20..13d67bc7 100644
--- a/test/test_static_symlink.py
+++ b/test/test_static_symlink.py
@@ -10,21 +10,21 @@ class TestStaticSymlink(TestApplicationProto):
@pytest.fixture(autouse=True)
def setup_method_fixture(self, temp_dir):
- os.makedirs(temp_dir + '/assets/dir/dir')
- Path(temp_dir + '/assets/index.html').write_text('0123456789')
- Path(temp_dir + '/assets/dir/file').write_text('blah')
+ os.makedirs(f'{temp_dir}/assets/dir/dir')
+ Path(f'{temp_dir}/assets/index.html').write_text('0123456789')
+ Path(f'{temp_dir}/assets/dir/file').write_text('blah')
self._load_conf(
{
"listeners": {"*:7080": {"pass": "routes"}},
- "routes": [{"action": {"share": temp_dir + "/assets$uri"}}],
+ "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
}
)
def test_static_symlink(self, temp_dir, skip_alert):
skip_alert(r'opening.*failed')
- os.symlink(temp_dir + '/assets/dir', temp_dir + '/assets/link')
+ os.symlink(f'{temp_dir}/assets/dir', f'{temp_dir}/assets/link')
assert self.get(url='/dir')['status'] == 301, 'dir'
assert self.get(url='/dir/file')['status'] == 200, 'file'
@@ -32,14 +32,14 @@ class TestStaticSymlink(TestApplicationProto):
assert self.get(url='/link/file')['status'] == 200, 'symlink file'
assert 'success' in self.conf(
- {"share": temp_dir + "/assets$uri", "follow_symlinks": False},
+ {"share": f'{temp_dir}/assets$uri', "follow_symlinks": False},
'routes/0/action',
), 'configure symlink disable'
assert self.get(url='/link/file')['status'] == 403, 'symlink disabled'
assert 'success' in self.conf(
- {"share": temp_dir + "/assets$uri", "follow_symlinks": True},
+ {"share": f'{temp_dir}/assets$uri', "follow_symlinks": True},
'routes/0/action',
), 'configure symlink enable'
@@ -48,21 +48,21 @@ class TestStaticSymlink(TestApplicationProto):
def test_static_symlink_two_blocks(self, temp_dir, skip_alert):
skip_alert(r'opening.*failed')
- os.symlink(temp_dir + '/assets/dir', temp_dir + '/assets/link')
+ os.symlink(f'{temp_dir}/assets/dir', f'{temp_dir}/assets/link')
assert 'success' in self.conf(
[
{
"match": {"method": "HEAD"},
"action": {
- "share": temp_dir + "/assets$uri",
+ "share": f'{temp_dir}/assets$uri',
"follow_symlinks": False,
},
},
{
"match": {"method": "GET"},
"action": {
- "share": temp_dir + "/assets$uri",
+ "share": f'{temp_dir}/assets$uri',
"follow_symlinks": True,
},
},
@@ -77,15 +77,15 @@ class TestStaticSymlink(TestApplicationProto):
skip_alert(r'opening.*failed')
os.symlink(
- temp_dir + '/assets/dir/file', temp_dir + '/assets/dir/dir/link'
+ f'{temp_dir}/assets/dir/file', f'{temp_dir}/assets/dir/dir/link'
)
assert self.get(url='/dir/dir/link')['status'] == 200, 'default chroot'
assert 'success' in self.conf(
{
- "share": temp_dir + "/assets$uri",
- "chroot": temp_dir + "/assets/dir/dir",
+ "share": f'{temp_dir}/assets$uri',
+ "chroot": f'{temp_dir}/assets/dir/dir',
},
'routes/0/action',
), 'configure chroot'