summaryrefslogtreecommitdiffhomepage
path: root/test/unit/check
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2024-01-15 15:48:58 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2024-01-15 15:48:58 +0000
commit5a8337933df1cf3aba967d86549e236dd9173386 (patch)
tree30842acf799fc521702b1c4b070332c72feaaa1c /test/unit/check
parente95a91cbfac018b9877d9e389e614e9f2a9f1313 (diff)
downloadunit-5a8337933df1cf3aba967d86549e236dd9173386.tar.gz
unit-5a8337933df1cf3aba967d86549e236dd9173386.tar.bz2
Tests: pathlib used where appropriate
Also fixed various pylint errors and style issues.
Diffstat (limited to 'test/unit/check')
-rw-r--r--test/unit/check/check_prerequisites.py1
-rw-r--r--test/unit/check/isolation.py13
-rw-r--r--test/unit/check/node.py4
3 files changed, 10 insertions, 8 deletions
diff --git a/test/unit/check/check_prerequisites.py b/test/unit/check/check_prerequisites.py
index 44c3f10f..ea319346 100644
--- a/test/unit/check/check_prerequisites.py
+++ b/test/unit/check/check_prerequisites.py
@@ -1,4 +1,5 @@
import pytest
+
from unit.option import option
diff --git a/test/unit/check/isolation.py b/test/unit/check/isolation.py
index e31179e8..861c0818 100644
--- a/test/unit/check/isolation.py
+++ b/test/unit/check/isolation.py
@@ -1,5 +1,5 @@
import json
-import os
+from pathlib import Path
from unit.applications.lang.go import ApplicationGo
from unit.applications.lang.java import ApplicationJava
@@ -145,11 +145,12 @@ def check_isolation():
isolation = {'user': userns}
- unp_clone_path = '/proc/sys/kernel/unprivileged_userns_clone'
- if os.path.exists(unp_clone_path):
- with open(unp_clone_path, 'r') as f:
- if str(f.read()).rstrip() == '1':
- isolation['unprivileged_userns_clone'] = True
+ path_clone = Path('/proc/sys/kernel/unprivileged_userns_clone')
+ if (
+ path_clone.exists()
+ and path_clone.read_text(encoding='utf-8').rstrip() == '1'
+ ):
+ isolation['unprivileged_userns_clone'] = True
for ns in allns:
ns_value = getns(ns)
diff --git a/test/unit/check/node.py b/test/unit/check/node.py
index 6a3d581f..b206e914 100644
--- a/test/unit/check/node.py
+++ b/test/unit/check/node.py
@@ -1,11 +1,11 @@
-import os
import subprocess
+from pathlib import Path
from unit.option import option
def check_node():
- if not os.path.exists(f'{option.current_dir}/node/node_modules'):
+ if not Path(f'{option.current_dir}/node/node_modules').exists():
return False
try: