py2docfx 0.1.20rc2245107__py3-none-any.whl → 0.1.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. py2docfx/convert_prepare/get_source.py +1 -1
  2. py2docfx/convert_prepare/package_info.py +37 -27
  3. py2docfx/convert_prepare/tests/test_get_source.py +3 -1
  4. py2docfx/convert_prepare/tests/test_package_info.py +159 -1
  5. py2docfx/docfx_yaml/build_finished.py +1 -1
  6. py2docfx/docfx_yaml/logger.py +42 -28
  7. py2docfx/venv/venv1/Lib/site-packages/psutil/__init__.py +39 -19
  8. py2docfx/venv/venv1/Lib/site-packages/psutil/_common.py +3 -5
  9. py2docfx/venv/venv1/Lib/site-packages/psutil/_psaix.py +1 -2
  10. py2docfx/venv/venv1/Lib/site-packages/psutil/_psbsd.py +53 -78
  11. py2docfx/venv/venv1/Lib/site-packages/psutil/_pslinux.py +55 -38
  12. py2docfx/venv/venv1/Lib/site-packages/psutil/_psosx.py +40 -12
  13. py2docfx/venv/venv1/Lib/site-packages/psutil/_psposix.py +0 -1
  14. py2docfx/venv/venv1/Lib/site-packages/psutil/_pssunos.py +1 -2
  15. py2docfx/venv/venv1/Lib/site-packages/psutil/_pswindows.py +33 -13
  16. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__init__.py +185 -122
  17. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__main__.py +2 -3
  18. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_bsd.py +5 -10
  19. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_connections.py +3 -4
  20. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_contracts.py +41 -45
  21. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_linux.py +35 -38
  22. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_memleaks.py +4 -8
  23. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_misc.py +6 -12
  24. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_osx.py +17 -8
  25. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_posix.py +29 -17
  26. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process.py +74 -75
  27. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process_all.py +11 -13
  28. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_scripts.py +2 -3
  29. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_sudo.py +117 -0
  30. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_system.py +21 -31
  31. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_testutils.py +23 -23
  32. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_unicode.py +15 -8
  33. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_windows.py +65 -33
  34. {py2docfx-0.1.20rc2245107.dist-info → py2docfx-0.1.21.dist-info}/METADATA +1 -1
  35. {py2docfx-0.1.20rc2245107.dist-info → py2docfx-0.1.21.dist-info}/RECORD +37 -36
  36. {py2docfx-0.1.20rc2245107.dist-info → py2docfx-0.1.21.dist-info}/WHEEL +0 -0
  37. {py2docfx-0.1.20rc2245107.dist-info → py2docfx-0.1.21.dist-info}/top_level.txt +0 -0
@@ -4,7 +4,6 @@
4
4
 
5
5
  """Test utilities."""
6
6
 
7
-
8
7
  import atexit
9
8
  import contextlib
10
9
  import ctypes
@@ -30,13 +29,13 @@ import tempfile
30
29
  import textwrap
31
30
  import threading
32
31
  import time
32
+ import traceback
33
33
  import unittest
34
34
  import warnings
35
35
  from socket import AF_INET
36
36
  from socket import AF_INET6
37
37
  from socket import SOCK_STREAM
38
38
 
39
-
40
39
  try:
41
40
  import pytest
42
41
  except ImportError:
@@ -57,7 +56,6 @@ from psutil._common import memoize
57
56
  from psutil._common import print_color
58
57
  from psutil._common import supports_ipv6
59
58
 
60
-
61
59
  if POSIX:
62
60
  from psutil._psposix import wait_pid
63
61
 
@@ -75,7 +73,7 @@ __all__ = [
75
73
  "HAS_SENSORS_TEMPERATURES", "HAS_NET_CONNECTIONS_UNIX", "MACOS_11PLUS",
76
74
  "MACOS_12PLUS", "COVERAGE", 'AARCH64', "PYTEST_PARALLEL",
77
75
  # subprocesses
78
- 'pyrun', 'terminate', 'reap_children', 'spawn_testproc', 'spawn_zombie',
76
+ 'pyrun', 'terminate', 'reap_children', 'spawn_subproc', 'spawn_zombie',
79
77
  'spawn_children_pair',
80
78
  # threads
81
79
  'ThreadTask',
@@ -116,7 +114,9 @@ COVERAGE = 'COVERAGE_RUN' in os.environ
116
114
  PYTEST_PARALLEL = "PYTEST_XDIST_WORKER" in os.environ # `make test-parallel`
117
115
  # are we a 64 bit process?
118
116
  IS_64BIT = sys.maxsize > 2**32
119
- AARCH64 = platform.machine() == "aarch64"
117
+ # apparently they're the same
118
+ AARCH64 = platform.machine().lower() in {"aarch64", "arm64"}
119
+ RISCV64 = platform.machine() == "riscv64"
120
120
 
121
121
 
122
122
  @memoize
@@ -190,7 +190,6 @@ HERE = os.path.realpath(os.path.dirname(__file__))
190
190
  # --- support
191
191
 
192
192
  HAS_CPU_AFFINITY = hasattr(psutil.Process, "cpu_affinity")
193
- HAS_CPU_FREQ = hasattr(psutil, "cpu_freq")
194
193
  HAS_ENVIRON = hasattr(psutil.Process, "environ")
195
194
  HAS_GETLOADAVG = hasattr(psutil, "getloadavg")
196
195
  HAS_IONICE = hasattr(psutil.Process, "ionice")
@@ -201,15 +200,23 @@ HAS_PROC_CPU_NUM = hasattr(psutil.Process, "cpu_num")
201
200
  HAS_PROC_IO_COUNTERS = hasattr(psutil.Process, "io_counters")
202
201
  HAS_RLIMIT = hasattr(psutil.Process, "rlimit")
203
202
  HAS_SENSORS_BATTERY = hasattr(psutil, "sensors_battery")
204
- try:
205
- HAS_BATTERY = HAS_SENSORS_BATTERY and bool(psutil.sensors_battery())
206
- except Exception: # noqa: BLE001
207
- HAS_BATTERY = False
208
203
  HAS_SENSORS_FANS = hasattr(psutil, "sensors_fans")
209
204
  HAS_SENSORS_TEMPERATURES = hasattr(psutil, "sensors_temperatures")
210
205
  HAS_THREADS = hasattr(psutil.Process, "threads")
211
206
  SKIP_SYSCONS = (MACOS or AIX) and os.getuid() != 0
212
207
 
208
+ try:
209
+ HAS_BATTERY = HAS_SENSORS_BATTERY and bool(psutil.sensors_battery())
210
+ except Exception: # noqa: BLE001
211
+ atexit.register(functools.partial(print, traceback.format_exc()))
212
+ HAS_BATTERY = False
213
+ try:
214
+ HAS_CPU_FREQ = hasattr(psutil, "cpu_freq") and bool(psutil.cpu_freq())
215
+ except Exception: # noqa: BLE001
216
+ atexit.register(functools.partial(print, traceback.format_exc()))
217
+ HAS_CPU_FREQ = False
218
+
219
+
213
220
  # --- misc
214
221
 
215
222
 
@@ -270,6 +277,110 @@ _subprocesses_started = set()
270
277
  _pids_started = set()
271
278
 
272
279
 
280
+ # ===================================================================
281
+ # --- fake pytest
282
+ # ===================================================================
283
+
284
+
285
+ class fake_pytest:
286
+ """A class that mimics some basic pytest APIs. This is meant for
287
+ when unit tests are run in production, where pytest may not be
288
+ installed. Still, the user can test psutil installation via:
289
+
290
+ $ python3 -m psutil.tests
291
+ """
292
+
293
+ @staticmethod
294
+ def _warn_on_exit():
295
+ def _warn_on_exit():
296
+ warnings.warn(
297
+ "Fake pytest module was used. Test results may be inaccurate.",
298
+ UserWarning,
299
+ stacklevel=1,
300
+ )
301
+
302
+ atexit.register(_warn_on_exit)
303
+
304
+ @staticmethod
305
+ def main(*args, **kw): # noqa: ARG004
306
+ """Mimics pytest.main(). It has the same effect as running
307
+ `python3 -m unittest -v` from the project root directory.
308
+ """
309
+ suite = unittest.TestLoader().discover(HERE)
310
+ unittest.TextTestRunner(verbosity=2).run(suite)
311
+ return suite
312
+
313
+ @staticmethod
314
+ def raises(exc, match=None):
315
+ """Mimics `pytest.raises`."""
316
+
317
+ class ExceptionInfo:
318
+ _exc = None
319
+
320
+ @property
321
+ def value(self):
322
+ return self._exc
323
+
324
+ @contextlib.contextmanager
325
+ def context(exc, match=None):
326
+ einfo = ExceptionInfo()
327
+ try:
328
+ yield einfo
329
+ except exc as err:
330
+ if match and not re.search(match, str(err)):
331
+ msg = f'"{match}" does not match "{err}"'
332
+ raise AssertionError(msg)
333
+ einfo._exc = err
334
+ else:
335
+ raise AssertionError(f"{exc!r} not raised")
336
+
337
+ return context(exc, match=match)
338
+
339
+ @staticmethod
340
+ def warns(warning, match=None):
341
+ """Mimics `pytest.warns`."""
342
+ if match:
343
+ return unittest.TestCase().assertWarnsRegex(warning, match)
344
+ return unittest.TestCase().assertWarns(warning)
345
+
346
+ @staticmethod
347
+ def skip(reason=""):
348
+ """Mimics `unittest.SkipTest`."""
349
+ raise unittest.SkipTest(reason)
350
+
351
+ @staticmethod
352
+ def fail(reason=""):
353
+ """Mimics `pytest.fail`."""
354
+ return unittest.TestCase().fail(reason)
355
+
356
+ class mark:
357
+
358
+ @staticmethod
359
+ def skipif(condition, reason=""):
360
+ """Mimics `@pytest.mark.skipif` decorator."""
361
+ return unittest.skipIf(condition, reason)
362
+
363
+ class xdist_group:
364
+ """Mimics `@pytest.mark.xdist_group` decorator (no-op)."""
365
+
366
+ def __init__(self, name=None):
367
+ pass
368
+
369
+ def __call__(self, cls_or_meth):
370
+ return cls_or_meth
371
+
372
+
373
+ # to make pytest.fail() exception catchable
374
+ fake_pytest.fail.Exception = AssertionError
375
+
376
+
377
+ if pytest is None:
378
+ pytest = fake_pytest
379
+ # monkey patch future `import pytest` statements
380
+ sys.modules["pytest"] = fake_pytest
381
+ fake_pytest._warn_on_exit()
382
+
383
+
273
384
  # ===================================================================
274
385
  # --- threads
275
386
  # ===================================================================
@@ -336,7 +447,7 @@ def _reap_children_on_err(fun):
336
447
 
337
448
 
338
449
  @_reap_children_on_err
339
- def spawn_testproc(cmd=None, **kwds):
450
+ def spawn_subproc(cmd=None, **kwds):
340
451
  """Create a python subprocess which does nothing for some secs and
341
452
  return it as a subprocess.Popen instance.
342
453
  If "cmd" is specified that is used instead of python.
@@ -469,7 +580,7 @@ def pyrun(src, **kwds):
469
580
  try:
470
581
  with open(srcfile, "w") as f:
471
582
  f.write(src)
472
- subp = spawn_testproc([PYTHON_EXE, f.name], **kwds)
583
+ subp = spawn_subproc([PYTHON_EXE, f.name], **kwds)
473
584
  wait_for_pid(subp.pid)
474
585
  return (subp, srcfile)
475
586
  except Exception:
@@ -750,7 +861,7 @@ def wait_for_file(fname, delete=True, empty=False):
750
861
 
751
862
 
752
863
  @retry(
753
- exception=AssertionError,
864
+ exception=(AssertionError, pytest.fail.Exception),
754
865
  logfun=None,
755
866
  timeout=GLOBAL_TIMEOUT,
756
867
  interval=0.001,
@@ -876,103 +987,43 @@ def get_testfn(suffix="", dir=None):
876
987
  # ===================================================================
877
988
 
878
989
 
879
- class fake_pytest:
880
- """A class that mimics some basic pytest APIs. This is meant for
881
- when unit tests are run in production, where pytest may not be
882
- installed. Still, the user can test psutil installation via:
883
-
884
- $ python3 -m psutil.tests
885
- """
886
-
887
- @staticmethod
888
- def main(*args, **kw): # noqa: ARG004
889
- """Mimics pytest.main(). It has the same effect as running
890
- `python3 -m unittest -v` from the project root directory.
891
- """
892
- suite = unittest.TestLoader().discover(HERE)
893
- unittest.TextTestRunner(verbosity=2).run(suite)
894
- warnings.warn(
895
- "Fake pytest module was used. Test results may be inaccurate.",
896
- UserWarning,
897
- stacklevel=1,
898
- )
899
- return suite
900
-
901
- @staticmethod
902
- def raises(exc, match=None):
903
- """Mimics `pytest.raises`."""
904
-
905
- class ExceptionInfo:
906
- _exc = None
907
-
908
- @property
909
- def value(self):
910
- return self._exc
911
-
912
- @contextlib.contextmanager
913
- def context(exc, match=None):
914
- einfo = ExceptionInfo()
915
- try:
916
- yield einfo
917
- except exc as err:
918
- if match and not re.search(match, str(err)):
919
- msg = f'"{match}" does not match "{err}"'
920
- raise AssertionError(msg)
921
- einfo._exc = err
922
- else:
923
- raise AssertionError(f"{exc!r} not raised")
924
-
925
- return context(exc, match=match)
926
-
927
- @staticmethod
928
- def warns(warning, match=None):
929
- """Mimics `pytest.warns`."""
930
- if match:
931
- return unittest.TestCase().assertWarnsRegex(warning, match)
932
- return unittest.TestCase().assertWarns(warning)
933
-
934
- @staticmethod
935
- def skip(reason=""):
936
- """Mimics `unittest.SkipTest`."""
937
- raise unittest.SkipTest(reason)
938
-
939
- class mark:
940
-
941
- @staticmethod
942
- def skipif(condition, reason=""):
943
- """Mimics `@pytest.mark.skipif` decorator."""
944
- return unittest.skipIf(condition, reason)
945
-
946
- class xdist_group:
947
- """Mimics `@pytest.mark.xdist_group` decorator (no-op)."""
948
-
949
- def __init__(self, name=None):
950
- pass
951
-
952
- def __call__(self, cls_or_meth):
953
- return cls_or_meth
954
-
955
-
956
- if pytest is None:
957
- pytest = fake_pytest
958
-
959
-
960
990
  class PsutilTestCase(unittest.TestCase):
961
991
  """Test class providing auto-cleanup wrappers on top of process
962
992
  test utilities. All test classes should derive from this one, even
963
993
  if we use pytest.
964
994
  """
965
995
 
996
+ # Print a full path representation of the single unit test being
997
+ # run, similar to pytest output. Used only when running tests with
998
+ # the unittest runner.
999
+ def __str__(self):
1000
+ fqmod = self.__class__.__module__
1001
+ if not fqmod.startswith('psutil.'):
1002
+ fqmod = 'psutil.tests.' + fqmod
1003
+ return "{}.{}.{}".format(
1004
+ fqmod,
1005
+ self.__class__.__name__,
1006
+ self._testMethodName,
1007
+ )
1008
+
966
1009
  def get_testfn(self, suffix="", dir=None):
967
1010
  fname = get_testfn(suffix=suffix, dir=dir)
968
1011
  self.addCleanup(safe_rmpath, fname)
969
1012
  return fname
970
1013
 
971
- def spawn_testproc(self, *args, **kwds):
972
- sproc = spawn_testproc(*args, **kwds)
1014
+ def spawn_subproc(self, *args, **kwds):
1015
+ sproc = spawn_subproc(*args, **kwds)
973
1016
  self.addCleanup(terminate, sproc)
974
1017
  return sproc
975
1018
 
1019
+ def spawn_psproc(self, *args, **kwargs):
1020
+ sproc = self.spawn_subproc(*args, **kwargs)
1021
+ try:
1022
+ return psutil.Process(sproc.pid)
1023
+ except psutil.NoSuchProcess:
1024
+ self.assert_pid_gone(sproc.pid)
1025
+ raise
1026
+
976
1027
  def spawn_children_pair(self):
977
1028
  child1, child2 = spawn_children_pair()
978
1029
  self.addCleanup(terminate, child2)
@@ -1004,23 +1055,23 @@ class PsutilTestCase(unittest.TestCase):
1004
1055
  str(exc)
1005
1056
  repr(exc)
1006
1057
 
1007
- def assertPidGone(self, pid):
1058
+ def assert_pid_gone(self, pid):
1008
1059
  with pytest.raises(psutil.NoSuchProcess) as cm:
1009
1060
  try:
1010
1061
  psutil.Process(pid)
1011
1062
  except psutil.ZombieProcess:
1012
- raise AssertionError("wasn't supposed to raise ZombieProcess")
1063
+ raise pytest.fail("wasn't supposed to raise ZombieProcess")
1013
1064
  assert cm.value.pid == pid
1014
1065
  assert cm.value.name is None
1015
1066
  assert not psutil.pid_exists(pid), pid
1016
1067
  assert pid not in psutil.pids()
1017
1068
  assert pid not in [x.pid for x in psutil.process_iter()]
1018
1069
 
1019
- def assertProcessGone(self, proc):
1020
- self.assertPidGone(proc.pid)
1070
+ def assert_proc_gone(self, proc):
1071
+ self.assert_pid_gone(proc.pid)
1021
1072
  ns = process_namespace(proc)
1022
1073
  for fun, name in ns.iter(ns.all, clear_cache=True):
1023
- with self.subTest(proc=proc, name=name):
1074
+ with self.subTest(proc=str(proc), name=name):
1024
1075
  try:
1025
1076
  ret = fun()
1026
1077
  except psutil.ZombieProcess:
@@ -1035,13 +1086,15 @@ class PsutilTestCase(unittest.TestCase):
1035
1086
  raise AssertionError(msg)
1036
1087
  proc.wait(timeout=0) # assert not raise TimeoutExpired
1037
1088
 
1038
- def assertProcessZombie(self, proc):
1089
+ def assert_proc_zombie(self, proc):
1039
1090
  # A zombie process should always be instantiable.
1040
1091
  clone = psutil.Process(proc.pid)
1041
- # Cloned zombie on Open/NetBSD has null creation time, see:
1092
+ # Cloned zombie on Open/NetBSD/illumos/Solaris has null creation
1093
+ # time, see:
1042
1094
  # https://github.com/giampaolo/psutil/issues/2287
1095
+ # https://github.com/giampaolo/psutil/issues/2593
1043
1096
  assert proc == clone
1044
- if not (OPENBSD or NETBSD):
1097
+ if not (OPENBSD or NETBSD or SUNOS):
1045
1098
  assert hash(proc) == hash(clone)
1046
1099
  # Its status always be querable.
1047
1100
  assert proc.status() == psutil.STATUS_ZOMBIE
@@ -1058,7 +1111,7 @@ class PsutilTestCase(unittest.TestCase):
1058
1111
  # Call all methods.
1059
1112
  ns = process_namespace(proc)
1060
1113
  for fun, name in ns.iter(ns.all, clear_cache=True):
1061
- with self.subTest(proc=proc, name=name):
1114
+ with self.subTest(proc=str(proc), name=name):
1062
1115
  try:
1063
1116
  fun()
1064
1117
  except (psutil.ZombieProcess, psutil.AccessDenied) as exc:
@@ -1089,16 +1142,16 @@ class PsutilTestCase(unittest.TestCase):
1089
1142
  # Its parent should 'see' it (edit: not true on BSD and MACOS).
1090
1143
  # descendants = [x.pid for x in psutil.Process().children(
1091
1144
  # recursive=True)]
1092
- # self.assertIn(proc.pid, descendants)
1145
+ # assert proc.pid in descendants
1093
1146
 
1094
1147
  # __eq__ can't be relied upon because creation time may not be
1095
1148
  # querable.
1096
- # self.assertEqual(proc, psutil.Process(proc.pid))
1149
+ # assert proc == psutil.Process(proc.pid)
1097
1150
 
1098
1151
  # XXX should we also assume ppid() to be usable? Note: this
1099
1152
  # would be an important use case as the only way to get
1100
1153
  # rid of a zombie is to kill its parent.
1101
- # self.assertEqual(proc.ppid(), os.getpid())
1154
+ # assert proc == ppid(), os.getpid()
1102
1155
 
1103
1156
 
1104
1157
  @pytest.mark.skipif(PYPY, reason="unreliable on PYPY")
@@ -1180,13 +1233,13 @@ class TestMemoryLeak(PsutilTestCase):
1180
1233
  f"negative diff {diff!r} (gc probably collected a"
1181
1234
  " resource from a previous test)"
1182
1235
  )
1183
- raise self.fail(msg)
1236
+ raise pytest.fail(msg)
1184
1237
  if diff > 0:
1185
1238
  type_ = "fd" if POSIX else "handle"
1186
1239
  if diff > 1:
1187
1240
  type_ += "s"
1188
1241
  msg = f"{diff} unclosed {type_} after calling {fun!r}"
1189
- raise self.fail(msg)
1242
+ raise pytest.fail(msg)
1190
1243
 
1191
1244
  def _call_ntimes(self, fun, times):
1192
1245
  """Get 2 distinct memory samples, before and after having
@@ -1227,7 +1280,7 @@ class TestMemoryLeak(PsutilTestCase):
1227
1280
  self._log(msg)
1228
1281
  times += increase
1229
1282
  prev_mem = mem
1230
- raise self.fail(". ".join(messages))
1283
+ raise pytest.fail(". ".join(messages))
1231
1284
 
1232
1285
  # ---
1233
1286
 
@@ -1262,7 +1315,12 @@ class TestMemoryLeak(PsutilTestCase):
1262
1315
  """
1263
1316
 
1264
1317
  def call():
1265
- self.assertRaises(exc, fun)
1318
+ try:
1319
+ fun()
1320
+ except exc:
1321
+ pass
1322
+ else:
1323
+ raise pytest.fail(f"{fun} did not raise {exc}")
1266
1324
 
1267
1325
  self.execute(call, **kwargs)
1268
1326
 
@@ -1355,25 +1413,27 @@ def print_sysinfo():
1355
1413
  bytes2human(swap.used),
1356
1414
  bytes2human(swap.total),
1357
1415
  )
1416
+
1417
+ # constants
1418
+ constants = sorted(
1419
+ [k for k, v in globals().items() if k.isupper() and v is True]
1420
+ )
1421
+ info['constants'] = "\n ".join(constants)
1422
+
1423
+ # processes
1358
1424
  info['pids'] = len(psutil.pids())
1359
1425
  pinfo = psutil.Process().as_dict()
1360
1426
  pinfo.pop('memory_maps', None)
1427
+ pinfo["environ"] = {k: os.environ[k] for k in sorted(os.environ)}
1361
1428
  info['proc'] = pprint.pformat(pinfo)
1362
1429
 
1430
+ # print
1363
1431
  print("=" * 70, file=sys.stderr) # noqa: T201
1364
1432
  for k, v in info.items():
1365
1433
  print("{:<17} {}".format(k + ":", v), file=sys.stderr) # noqa: T201
1366
1434
  print("=" * 70, file=sys.stderr) # noqa: T201
1367
1435
  sys.stdout.flush()
1368
1436
 
1369
- # if WINDOWS:
1370
- # os.system("tasklist")
1371
- # elif shutil.which("ps"):
1372
- # os.system("ps aux")
1373
- # print("=" * 70, file=sys.stderr)
1374
-
1375
- sys.stdout.flush()
1376
-
1377
1437
 
1378
1438
  def is_win_secure_system_proc(pid):
1379
1439
  # see: https://github.com/giampaolo/psutil/issues/2338
@@ -1569,7 +1629,7 @@ class system_namespace:
1569
1629
  ('virtual_memory', (), {}),
1570
1630
  ]
1571
1631
  if HAS_CPU_FREQ:
1572
- if MACOS and platform.machine() == 'arm64': # skipped due to #1892
1632
+ if MACOS and AARCH64: # skipped due to #1892
1573
1633
  pass
1574
1634
  else:
1575
1635
  getters += [('cpu_freq', (), {'percpu': True})]
@@ -1618,7 +1678,10 @@ def retry_on_failure(retries=NO_RETRIES):
1618
1678
  print(f"{exc!r}, retrying", file=sys.stderr) # noqa: T201
1619
1679
 
1620
1680
  return retry(
1621
- exception=AssertionError, timeout=None, retries=retries, logfun=logfun
1681
+ exception=(AssertionError, pytest.fail.Exception),
1682
+ timeout=None,
1683
+ retries=retries,
1684
+ logfun=logfun,
1622
1685
  )
1623
1686
 
1624
1687
 
@@ -3,10 +3,9 @@
3
3
  # found in the LICENSE file.
4
4
 
5
5
  """Run unit tests. This is invoked by:
6
- $ python -m psutil.tests.
6
+ $ python3 -m psutil.tests.
7
7
  """
8
8
 
9
9
  from psutil.tests import pytest
10
10
 
11
-
12
- pytest.main(["-v", "-s", "--tb=short"])
11
+ pytest.main()
@@ -26,10 +26,9 @@ from psutil.tests import PsutilTestCase
26
26
  from psutil.tests import pytest
27
27
  from psutil.tests import retry_on_failure
28
28
  from psutil.tests import sh
29
- from psutil.tests import spawn_testproc
29
+ from psutil.tests import spawn_subproc
30
30
  from psutil.tests import terminate
31
31
 
32
-
33
32
  if BSD:
34
33
  from psutil._psutil_posix import getpagesize
35
34
 
@@ -78,7 +77,7 @@ class BSDTestCase(PsutilTestCase):
78
77
 
79
78
  @classmethod
80
79
  def setUpClass(cls):
81
- cls.pid = spawn_testproc().pid
80
+ cls.pid = spawn_subproc().pid
82
81
 
83
82
  @classmethod
84
83
  def tearDownClass(cls):
@@ -117,9 +116,9 @@ class BSDTestCase(PsutilTestCase):
117
116
  assert usage.total == total
118
117
  # 10 MB tolerance
119
118
  if abs(usage.free - free) > 10 * 1024 * 1024:
120
- raise self.fail(f"psutil={usage.free}, df={free}")
119
+ raise pytest.fail(f"psutil={usage.free}, df={free}")
121
120
  if abs(usage.used - used) > 10 * 1024 * 1024:
122
- raise self.fail(f"psutil={usage.used}, df={used}")
121
+ raise pytest.fail(f"psutil={usage.used}, df={used}")
123
122
 
124
123
  @pytest.mark.skipif(
125
124
  not shutil.which("sysctl"), reason="sysctl cmd not available"
@@ -162,7 +161,7 @@ class BSDTestCase(PsutilTestCase):
162
161
  class FreeBSDPsutilTestCase(PsutilTestCase):
163
162
  @classmethod
164
163
  def setUpClass(cls):
165
- cls.pid = spawn_testproc().pid
164
+ cls.pid = spawn_subproc().pid
166
165
 
167
166
  @classmethod
168
167
  def tearDownClass(cls):
@@ -389,10 +388,6 @@ class FreeBSDSystemTestCase(PsutilTestCase):
389
388
  < 200000
390
389
  )
391
390
 
392
- # def test_cpu_stats_traps(self):
393
- # self.assertAlmostEqual(psutil.cpu_stats().traps,
394
- # sysctl('vm.stats.sys.v_trap'), delta=1000)
395
-
396
391
  # --- swap memory
397
392
 
398
393
  def test_swapmem_free(self):
@@ -42,7 +42,6 @@ from psutil.tests import tcp_socketpair
42
42
  from psutil.tests import unix_socketpair
43
43
  from psutil.tests import wait_for_file
44
44
 
45
-
46
45
  SOCK_SEQPACKET = getattr(socket, "SOCK_SEQPACKET", object())
47
46
 
48
47
 
@@ -204,7 +203,7 @@ class TestConnectedSocket(ConnectionTestCase):
204
203
 
205
204
  # On SunOS, even after we close() it, the server socket stays around
206
205
  # in TIME_WAIT state.
207
- @pytest.mark.skipif(SUNOS, reason="unreliable on SUONS")
206
+ @pytest.mark.skipif(SUNOS, reason="unreliable on SUNOS")
208
207
  def test_tcp(self):
209
208
  addr = ("127.0.0.1", 0)
210
209
  assert this_proc_net_connections(kind='tcp4') == []
@@ -218,8 +217,8 @@ class TestConnectedSocket(ConnectionTestCase):
218
217
  # commenteed.
219
218
  # client.close()
220
219
  # cons = this_proc_net_connections(kind='all')
221
- # self.assertEqual(len(cons), 1)
222
- # self.assertEqual(cons[0].status, psutil.CONN_CLOSE_WAIT)
220
+ # assert len(cons) == 1
221
+ # assert cons[0].status == psutil.CONN_CLOSE_WAIT
223
222
  finally:
224
223
  server.close()
225
224
  client.close()