summaryrefslogtreecommitdiff
path: root/psutil/tests
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2023-04-22 20:00:03 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2023-04-22 20:00:03 +0000
commit12fe73d2ed9c10ee5fa9b2e9fe00a2a27fe77e22 (patch)
tree80e7bd56e4d5f11f55eed40930696c0d9642e956 /psutil/tests
parent995fa82a5f0b5013ca5535a9f1669c96d07ef4ca (diff)
downloadpsutil-12fe73d2ed9c10ee5fa9b2e9fe00a2a27fe77e22.tar.gz
SunOS: fix some C compilation warnings
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Diffstat (limited to 'psutil/tests')
-rwxr-xr-xpsutil/tests/test_posix.py11
-rwxr-xr-xpsutil/tests/test_sunos.py7
2 files changed, 10 insertions, 8 deletions
diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py
index 9ce82cae..c789ee87 100755
--- a/psutil/tests/test_posix.py
+++ b/psutil/tests/test_posix.py
@@ -62,10 +62,7 @@ def ps(fmt, pid=None):
cmd.append('ax')
if SUNOS:
- # XXX: set() has not get() method so this cannot work; not sure
- # what I meant in here.
- fmt_map = set(('command', 'comm', 'start', 'stime'))
- fmt = fmt_map.get(fmt, fmt)
+ fmt = fmt.replace("start", "stime")
cmd.extend(['-o', fmt])
@@ -373,6 +370,12 @@ class TestSystemAPIs(PsutilTestCase):
started = re.findall(r"[A-Z][a-z][a-z] \d\d", out)
if started:
tstamp = "%b %d"
+ else:
+ # 'apr 10' (sunOS)
+ started = re.findall(r"[a-z][a-z][a-z] \d\d", out)
+ if started:
+ tstamp = "%b %d"
+ started = [x.capitalize() for x in started]
if not tstamp:
raise ValueError(
diff --git a/psutil/tests/test_sunos.py b/psutil/tests/test_sunos.py
index dd74a49b..274584d6 100755
--- a/psutil/tests/test_sunos.py
+++ b/psutil/tests/test_sunos.py
@@ -25,10 +25,9 @@ class SunOSSpecificTestCase(PsutilTestCase):
raise ValueError('no swap device(s) configured')
total = free = 0
for line in lines:
- line = line.split()
- t, f = line[-2:]
- total += int(int(t) * 512)
- free += int(int(f) * 512)
+ fields = line.split()
+ total = int(fields[3]) * 512
+ free = int(fields[4]) * 512
used = total - free
psutil_swap = psutil.swap_memory()