Skip to content

Commit df607b1

Browse files
committed
Silence output of some tests + fix NetBSD build
1 parent 63beda8 commit df607b1

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

psutil/arch/bsd/proc_utils.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#include <stdint.h>
1212
#include <sys/types.h>
1313
#include <sys/sysctl.h>
14-
#include <sys/user.h>
1514
#include <sys/proc.h>
1615
#include <limits.h>
1716
#include <unistd.h>
17+
#ifdef PSUTIL_FREEBSD
18+
#include <sys/user.h>
19+
#endif
1820

1921
#include "../../arch/all/init.h"
2022

psutil/tests/test_scripts.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import pytest
1616

17+
from psutil import LINUX
1718
from psutil import POSIX
1819
from psutil import WINDOWS
1920
from psutil.tests import CI_TESTING
@@ -46,14 +47,13 @@
4647
)
4748
class TestExampleScripts(PsutilTestCase):
4849
@staticmethod
49-
def assert_stdout(exe, *args, **kwargs):
50-
kwargs.setdefault("env", PYTHON_EXE_ENV)
50+
def assert_stdout(exe, *args):
51+
env = PYTHON_EXE_ENV.copy()
52+
env.pop("PSUTIL_DEBUG") # avoid spamming to stderr
5153
exe = os.path.join(SCRIPTS_DIR, exe)
52-
cmd = [PYTHON_EXE, exe]
53-
for arg in args:
54-
cmd.append(arg)
54+
cmd = [PYTHON_EXE, exe, *args]
5555
try:
56-
out = sh(cmd, **kwargs).strip()
56+
out = sh(cmd, env=env).strip()
5757
except RuntimeError as err:
5858
if 'AccessDenied' in str(err):
5959
return str(err)
@@ -195,6 +195,8 @@ def test_syntax_all(self):
195195
data = f.read()
196196
ast.parse(data)
197197

198+
# don't care about other platforms, this is really just for myself
199+
@pytest.mark.skipif(not LINUX, reason="not on LINUX")
198200
@pytest.mark.skipif(CI_TESTING, reason="not on CI")
199201
def test_import_all(self):
200202
for path in self.ls():

scripts/procsmem.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ def main():
9595
)
9696
print(line)
9797
if ad_pids:
98-
print(
99-
f"warning: access denied for {len(ad_pids)} pids",
100-
file=sys.stderr,
101-
)
98+
print(f"warning: access denied for {len(ad_pids)} pids")
10299

103100

104101
if __name__ == '__main__':

0 commit comments

Comments
 (0)