summaryrefslogtreecommitdiffhomepage
path: root/test/test_usr1.py
diff options
context:
space:
mode:
authorDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
committerDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
commitd76761901c4084bcdbc5a449e9bbb47d56b7093c (patch)
treeb4b7b4e3d588b73a2adcc0094cab466d9194c679 /test/test_usr1.py
parentc43629880472bba8d389dfb0b7ae6d883b0ba499 (diff)
parent088117008c9e8f397a58cc8d8070ce047beff12f (diff)
downloadunit-d76761901c4084bcdbc5a449e9bbb47d56b7093c.tar.gz
unit-d76761901c4084bcdbc5a449e9bbb47d56b7093c.tar.bz2
Merge tag '1.32.0' into branches/packaging1.32.0-1
Unit 1.32.0 release.
Diffstat (limited to 'test/test_usr1.py')
-rw-r--r--test/test_usr1.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/test/test_usr1.py b/test/test_usr1.py
index ce756fc0..ecb4d8fd 100644
--- a/test/test_usr1.py
+++ b/test/test_usr1.py
@@ -1,5 +1,6 @@
import os
import signal
+from pathlib import Path
from unit.applications.lang.python import ApplicationPython
from unit.log import Log
@@ -23,14 +24,14 @@ def test_usr1_access_log(search_in_file, temp_dir, unit_pid, wait_for_record):
assert waitforfiles(log_path), 'open'
- os.rename(log_path, f'{temp_dir}/{log_new}')
+ Path(log_path).rename(f'{temp_dir}/{log_new}')
assert client.get()['status'] == 200
assert (
wait_for_record(r'"GET / HTTP/1.1" 200 0 "-" "-"', log_new) is not None
), 'rename new'
- assert not os.path.isfile(log_path), 'rename old'
+ assert not Path(log_path).is_file(), 'rename old'
os.kill(unit_pid, signal.SIGUSR1)
@@ -51,7 +52,7 @@ def test_usr1_unit_log(search_in_file, temp_dir, unit_pid, wait_for_record):
log_path = f'{temp_dir}/unit.log'
log_path_new = f'{temp_dir}/{log_new}'
- os.rename(log_path, log_path_new)
+ Path(log_path).rename(log_path_new)
Log.swap(log_new)
@@ -60,7 +61,7 @@ def test_usr1_unit_log(search_in_file, temp_dir, unit_pid, wait_for_record):
assert client.post(body=body)['status'] == 200
assert wait_for_record(body, log_new) is not None, 'rename new'
- assert not os.path.isfile(log_path), 'rename old'
+ assert not Path(log_path).is_file(), 'rename old'
os.kill(unit_pid, signal.SIGUSR1)
@@ -75,13 +76,10 @@ def test_usr1_unit_log(search_in_file, temp_dir, unit_pid, wait_for_record):
finally:
# merge two log files into unit.log to check alerts
- with open(log_path, 'r', errors='ignore') as unit_log:
- log = unit_log.read()
-
- with open(log_path, 'w') as unit_log, open(
- log_path_new, 'r', errors='ignore'
- ) as unit_log_new:
- unit_log.write(unit_log_new.read())
- unit_log.write(log)
+ path_log = Path(log_path)
+ log = path_log.read_text(encoding='utf-8', errors='ignore') + Path(
+ log_path_new
+ ).read_text(encoding='utf-8', errors='ignore')
+ path_log.write_text(log, encoding='utf-8', errors='ignore')
Log.swap(log_new)