py2docfx 0.1.20.dev2245319__py3-none-any.whl → 0.1.20.dev2246325__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.
- py2docfx/convert_prepare/package_info.py +27 -37
- py2docfx/convert_prepare/pip_utils.py +1 -3
- py2docfx/convert_prepare/tests/test_package_info.py +1 -159
- py2docfx/venv/venv1/Lib/site-packages/psutil/__init__.py +39 -19
- py2docfx/venv/venv1/Lib/site-packages/psutil/_common.py +3 -5
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psaix.py +1 -2
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psbsd.py +53 -78
- py2docfx/venv/venv1/Lib/site-packages/psutil/_pslinux.py +55 -38
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psosx.py +40 -12
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psposix.py +0 -1
- py2docfx/venv/venv1/Lib/site-packages/psutil/_pssunos.py +1 -2
- py2docfx/venv/venv1/Lib/site-packages/psutil/_pswindows.py +33 -13
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__init__.py +185 -122
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__main__.py +2 -3
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_bsd.py +5 -10
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_connections.py +3 -4
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_contracts.py +41 -45
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_linux.py +35 -38
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_memleaks.py +4 -8
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_misc.py +6 -12
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_osx.py +17 -8
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_posix.py +29 -17
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process.py +74 -75
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process_all.py +11 -13
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_scripts.py +2 -3
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_sudo.py +117 -0
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_system.py +21 -31
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_testutils.py +23 -23
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_unicode.py +15 -8
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_windows.py +65 -33
- {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2246325.dist-info}/METADATA +1 -1
- {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2246325.dist-info}/RECORD +34 -33
- {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2246325.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2246325.dist-info}/top_level.txt +0 -0
@@ -10,7 +10,6 @@ import datetime
|
|
10
10
|
import enum
|
11
11
|
import errno
|
12
12
|
import os
|
13
|
-
import platform
|
14
13
|
import pprint
|
15
14
|
import shutil
|
16
15
|
import signal
|
@@ -43,7 +42,6 @@ from psutil.tests import HAS_NET_IO_COUNTERS
|
|
43
42
|
from psutil.tests import HAS_SENSORS_BATTERY
|
44
43
|
from psutil.tests import HAS_SENSORS_FANS
|
45
44
|
from psutil.tests import HAS_SENSORS_TEMPERATURES
|
46
|
-
from psutil.tests import IS_64BIT
|
47
45
|
from psutil.tests import MACOS_12PLUS
|
48
46
|
from psutil.tests import PYPY
|
49
47
|
from psutil.tests import UNICODE_SUFFIX
|
@@ -52,7 +50,6 @@ from psutil.tests import check_net_address
|
|
52
50
|
from psutil.tests import pytest
|
53
51
|
from psutil.tests import retry_on_failure
|
54
52
|
|
55
|
-
|
56
53
|
# ===================================================================
|
57
54
|
# --- System-related API tests
|
58
55
|
# ===================================================================
|
@@ -61,7 +58,7 @@ from psutil.tests import retry_on_failure
|
|
61
58
|
class TestProcessIter(PsutilTestCase):
|
62
59
|
def test_pid_presence(self):
|
63
60
|
assert os.getpid() in [x.pid for x in psutil.process_iter()]
|
64
|
-
sproc = self.
|
61
|
+
sproc = self.spawn_subproc()
|
65
62
|
assert sproc.pid in [x.pid for x in psutil.process_iter()]
|
66
63
|
p = psutil.Process(sproc.pid)
|
67
64
|
p.kill()
|
@@ -133,16 +130,16 @@ class TestProcessIter(PsutilTestCase):
|
|
133
130
|
class TestProcessAPIs(PsutilTestCase):
|
134
131
|
@pytest.mark.skipif(
|
135
132
|
PYPY and WINDOWS,
|
136
|
-
reason="
|
133
|
+
reason="spawn_subproc() unreliable on PYPY + WINDOWS",
|
137
134
|
)
|
138
135
|
def test_wait_procs(self):
|
139
136
|
def callback(p):
|
140
137
|
pids.append(p.pid)
|
141
138
|
|
142
139
|
pids = []
|
143
|
-
sproc1 = self.
|
144
|
-
sproc2 = self.
|
145
|
-
sproc3 = self.
|
140
|
+
sproc1 = self.spawn_subproc()
|
141
|
+
sproc2 = self.spawn_subproc()
|
142
|
+
sproc3 = self.spawn_subproc()
|
146
143
|
procs = [psutil.Process(x.pid) for x in (sproc1, sproc2, sproc3)]
|
147
144
|
with pytest.raises(ValueError):
|
148
145
|
psutil.wait_procs(procs, timeout=-1)
|
@@ -196,19 +193,19 @@ class TestProcessAPIs(PsutilTestCase):
|
|
196
193
|
|
197
194
|
@pytest.mark.skipif(
|
198
195
|
PYPY and WINDOWS,
|
199
|
-
reason="
|
196
|
+
reason="spawn_subproc() unreliable on PYPY + WINDOWS",
|
200
197
|
)
|
201
198
|
def test_wait_procs_no_timeout(self):
|
202
|
-
sproc1 = self.
|
203
|
-
sproc2 = self.
|
204
|
-
sproc3 = self.
|
199
|
+
sproc1 = self.spawn_subproc()
|
200
|
+
sproc2 = self.spawn_subproc()
|
201
|
+
sproc3 = self.spawn_subproc()
|
205
202
|
procs = [psutil.Process(x.pid) for x in (sproc1, sproc2, sproc3)]
|
206
203
|
for p in procs:
|
207
204
|
p.terminate()
|
208
205
|
psutil.wait_procs(procs)
|
209
206
|
|
210
207
|
def test_pid_exists(self):
|
211
|
-
sproc = self.
|
208
|
+
sproc = self.spawn_subproc()
|
212
209
|
assert psutil.pid_exists(sproc.pid)
|
213
210
|
p = psutil.Process(sproc.pid)
|
214
211
|
p.kill()
|
@@ -325,9 +322,9 @@ class TestMemoryAPIs(PsutilTestCase):
|
|
325
322
|
assert isinstance(value, int)
|
326
323
|
if name != 'total':
|
327
324
|
if not value >= 0:
|
328
|
-
raise
|
325
|
+
raise pytest.fail(f"{name!r} < 0 ({value})")
|
329
326
|
if value > mem.total:
|
330
|
-
raise
|
327
|
+
raise pytest.fail(
|
331
328
|
f"{name!r} > total (total={mem.total}, {name}={value})"
|
332
329
|
)
|
333
330
|
|
@@ -417,9 +414,7 @@ class TestCpuAPIs(PsutilTestCase):
|
|
417
414
|
# for field in new._fields:
|
418
415
|
# new_t = getattr(new, field)
|
419
416
|
# last_t = getattr(last, field)
|
420
|
-
#
|
421
|
-
# new_t, last_t,
|
422
|
-
# msg="{} {}".format(new_t, last_t))
|
417
|
+
# assert new_t >= last_t
|
423
418
|
# last = new
|
424
419
|
|
425
420
|
def test_cpu_times_time_increases(self):
|
@@ -430,7 +425,7 @@ class TestCpuAPIs(PsutilTestCase):
|
|
430
425
|
t2 = sum(psutil.cpu_times())
|
431
426
|
if t2 > t1:
|
432
427
|
return
|
433
|
-
raise
|
428
|
+
raise pytest.fail("time remained the same")
|
434
429
|
|
435
430
|
def test_per_cpu_times(self):
|
436
431
|
# Check type, value >= 0, str().
|
@@ -462,8 +457,7 @@ class TestCpuAPIs(PsutilTestCase):
|
|
462
457
|
# for field in newcpu._fields:
|
463
458
|
# new_t = getattr(newcpu, field)
|
464
459
|
# last_t = getattr(lastcpu, field)
|
465
|
-
#
|
466
|
-
# new_t, last_t, msg="{} {}".format(lastcpu, newcpu))
|
460
|
+
# assert new_t >= last_t
|
467
461
|
# last = new
|
468
462
|
|
469
463
|
def test_per_cpu_times_2(self):
|
@@ -473,7 +467,7 @@ class TestCpuAPIs(PsutilTestCase):
|
|
473
467
|
giveup_at = time.time() + GLOBAL_TIMEOUT
|
474
468
|
while True:
|
475
469
|
if time.time() >= giveup_at:
|
476
|
-
return
|
470
|
+
return pytest.fail("timeout")
|
477
471
|
tot2 = psutil.cpu_times(percpu=True)
|
478
472
|
for t1, t2 in zip(tot1, tot2):
|
479
473
|
t1, t2 = psutil._cpu_busy_time(t1), psutil._cpu_busy_time(t2)
|
@@ -482,7 +476,7 @@ class TestCpuAPIs(PsutilTestCase):
|
|
482
476
|
return None
|
483
477
|
|
484
478
|
@pytest.mark.skipif(
|
485
|
-
CI_TESTING and OPENBSD, reason="unreliable on OPENBSD + CI"
|
479
|
+
(CI_TESTING and OPENBSD) or MACOS, reason="unreliable on OPENBSD + CI"
|
486
480
|
)
|
487
481
|
@retry_on_failure(30)
|
488
482
|
def test_cpu_times_comparison(self):
|
@@ -582,9 +576,7 @@ class TestCpuAPIs(PsutilTestCase):
|
|
582
576
|
assert value > 0
|
583
577
|
|
584
578
|
# TODO: remove this once 1892 is fixed
|
585
|
-
@pytest.mark.skipif(
|
586
|
-
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
|
587
|
-
)
|
579
|
+
@pytest.mark.skipif(MACOS and AARCH64, reason="skipped due to #1892")
|
588
580
|
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
|
589
581
|
def test_cpu_freq(self):
|
590
582
|
def check_ls(ls):
|
@@ -619,9 +611,6 @@ class TestCpuAPIs(PsutilTestCase):
|
|
619
611
|
|
620
612
|
|
621
613
|
class TestDiskAPIs(PsutilTestCase):
|
622
|
-
@pytest.mark.skipif(
|
623
|
-
PYPY and not IS_64BIT, reason="unreliable on PYPY32 + 32BIT"
|
624
|
-
)
|
625
614
|
def test_disk_usage(self):
|
626
615
|
usage = psutil.disk_usage(os.getcwd())
|
627
616
|
assert usage._fields == ('total', 'used', 'free', 'percent')
|
@@ -810,8 +799,9 @@ class TestNetAPIs(PsutilTestCase):
|
|
810
799
|
|
811
800
|
# Not reliable on all platforms (net_if_addrs() reports more
|
812
801
|
# interfaces).
|
813
|
-
#
|
814
|
-
#
|
802
|
+
# assert sorted(nics.keys()) == sorted(
|
803
|
+
# psutil.net_io_counters(pernic=True).keys()
|
804
|
+
# )
|
815
805
|
|
816
806
|
families = {socket.AF_INET, socket.AF_INET6, psutil.AF_LINK}
|
817
807
|
for nic, addrs in nics.items():
|
@@ -56,7 +56,6 @@ from psutil.tests import unix_socketpair
|
|
56
56
|
from psutil.tests import wait_for_file
|
57
57
|
from psutil.tests import wait_for_pid
|
58
58
|
|
59
|
-
|
60
59
|
# ===================================================================
|
61
60
|
# --- Unit tests for test utilities.
|
62
61
|
# ===================================================================
|
@@ -218,7 +217,7 @@ class TestFSTestUtils(PsutilTestCase):
|
|
218
217
|
|
219
218
|
class TestProcessUtils(PsutilTestCase):
|
220
219
|
def test_reap_children(self):
|
221
|
-
subp = self.
|
220
|
+
subp = self.spawn_subproc()
|
222
221
|
p = psutil.Process(subp.pid)
|
223
222
|
assert p.is_running()
|
224
223
|
reap_children()
|
@@ -254,14 +253,14 @@ class TestProcessUtils(PsutilTestCase):
|
|
254
253
|
|
255
254
|
def test_terminate(self):
|
256
255
|
# by subprocess.Popen
|
257
|
-
p = self.
|
256
|
+
p = self.spawn_subproc()
|
258
257
|
terminate(p)
|
259
|
-
self.
|
258
|
+
self.assert_pid_gone(p.pid)
|
260
259
|
terminate(p)
|
261
260
|
# by psutil.Process
|
262
|
-
p = psutil.Process(self.
|
261
|
+
p = psutil.Process(self.spawn_subproc().pid)
|
263
262
|
terminate(p)
|
264
|
-
self.
|
263
|
+
self.assert_pid_gone(p.pid)
|
265
264
|
terminate(p)
|
266
265
|
# by psutil.Popen
|
267
266
|
cmd = [
|
@@ -276,20 +275,20 @@ class TestProcessUtils(PsutilTestCase):
|
|
276
275
|
env=PYTHON_EXE_ENV,
|
277
276
|
)
|
278
277
|
terminate(p)
|
279
|
-
self.
|
278
|
+
self.assert_pid_gone(p.pid)
|
280
279
|
terminate(p)
|
281
280
|
# by PID
|
282
|
-
pid = self.
|
281
|
+
pid = self.spawn_subproc().pid
|
283
282
|
terminate(pid)
|
284
|
-
self.
|
283
|
+
self.assert_pid_gone(p.pid)
|
285
284
|
terminate(pid)
|
286
285
|
# zombie
|
287
286
|
if POSIX:
|
288
287
|
parent, zombie = self.spawn_zombie()
|
289
288
|
terminate(parent)
|
290
289
|
terminate(zombie)
|
291
|
-
self.
|
292
|
-
self.
|
290
|
+
self.assert_pid_gone(parent.pid)
|
291
|
+
self.assert_pid_gone(zombie.pid)
|
293
292
|
|
294
293
|
|
295
294
|
class TestNetUtils(PsutilTestCase):
|
@@ -398,7 +397,7 @@ class TestMemLeakClass(TestMemoryLeak):
|
|
398
397
|
|
399
398
|
try:
|
400
399
|
# will consume around 60M in total
|
401
|
-
with pytest.raises(
|
400
|
+
with pytest.raises(pytest.fail.Exception, match="extra-mem"):
|
402
401
|
self.execute(fun, times=100)
|
403
402
|
finally:
|
404
403
|
del ls
|
@@ -411,7 +410,7 @@ class TestMemLeakClass(TestMemoryLeak):
|
|
411
410
|
|
412
411
|
box = []
|
413
412
|
kind = "fd" if POSIX else "handle"
|
414
|
-
with pytest.raises(
|
413
|
+
with pytest.raises(pytest.fail.Exception, match="unclosed " + kind):
|
415
414
|
self.execute(fun)
|
416
415
|
|
417
416
|
def test_tolerance(self):
|
@@ -436,7 +435,7 @@ class TestMemLeakClass(TestMemoryLeak):
|
|
436
435
|
def fun_2():
|
437
436
|
pass
|
438
437
|
|
439
|
-
with pytest.raises(
|
438
|
+
with pytest.raises(pytest.fail.Exception):
|
440
439
|
self.execute_w_exc(ZeroDivisionError, fun_2)
|
441
440
|
|
442
441
|
|
@@ -460,9 +459,9 @@ class TestFakePytest(PsutilTestCase):
|
|
460
459
|
with fake_pytest.raises(ValueError, match="foo") as cm:
|
461
460
|
raise ValueError("bar")
|
462
461
|
except AssertionError as err:
|
463
|
-
assert str(err) == '"foo" does not match "bar"'
|
462
|
+
assert str(err) == '"foo" does not match "bar"' # noqa: PT017
|
464
463
|
else:
|
465
|
-
raise
|
464
|
+
raise pytest.fail("exception not raised")
|
466
465
|
|
467
466
|
def test_mark(self):
|
468
467
|
@fake_pytest.mark.xdist_group(name="serial")
|
@@ -523,11 +522,8 @@ class TestFakePytest(PsutilTestCase):
|
|
523
522
|
pass
|
524
523
|
""").lstrip())
|
525
524
|
with mock.patch.object(psutil.tests, "HERE", tmpdir):
|
526
|
-
|
527
|
-
|
528
|
-
):
|
529
|
-
suite = fake_pytest.main()
|
530
|
-
assert suite.countTestCases() == 1
|
525
|
+
suite = fake_pytest.main()
|
526
|
+
assert suite.countTestCases() == 1
|
531
527
|
|
532
528
|
def test_warns(self):
|
533
529
|
# success
|
@@ -541,7 +537,7 @@ class TestFakePytest(PsutilTestCase):
|
|
541
537
|
except AssertionError:
|
542
538
|
pass
|
543
539
|
else:
|
544
|
-
raise
|
540
|
+
raise pytest.fail("exception not raised")
|
545
541
|
|
546
542
|
# match success
|
547
543
|
with fake_pytest.warns(UserWarning, match="foo"):
|
@@ -554,7 +550,11 @@ class TestFakePytest(PsutilTestCase):
|
|
554
550
|
except AssertionError:
|
555
551
|
pass
|
556
552
|
else:
|
557
|
-
raise
|
553
|
+
raise pytest.fail("exception not raised")
|
554
|
+
|
555
|
+
def test_fail(self):
|
556
|
+
with fake_pytest.raises(fake_pytest.fail.Exception):
|
557
|
+
raise fake_pytest.fail("reason")
|
558
558
|
|
559
559
|
|
560
560
|
class TestTestingUtils(PsutilTestCase):
|
@@ -73,6 +73,9 @@ from contextlib import closing
|
|
73
73
|
|
74
74
|
import psutil
|
75
75
|
from psutil import BSD
|
76
|
+
from psutil import MACOS
|
77
|
+
from psutil import NETBSD
|
78
|
+
from psutil import OPENBSD
|
76
79
|
from psutil import POSIX
|
77
80
|
from psutil import WINDOWS
|
78
81
|
from psutil.tests import ASCII_FS
|
@@ -94,7 +97,7 @@ from psutil.tests import pytest
|
|
94
97
|
from psutil.tests import safe_mkdir
|
95
98
|
from psutil.tests import safe_rmpath
|
96
99
|
from psutil.tests import skip_on_access_denied
|
97
|
-
from psutil.tests import
|
100
|
+
from psutil.tests import spawn_subproc
|
98
101
|
from psutil.tests import terminate
|
99
102
|
|
100
103
|
|
@@ -107,7 +110,7 @@ def try_unicode(suffix):
|
|
107
110
|
try:
|
108
111
|
safe_rmpath(testfn)
|
109
112
|
create_py_exe(testfn)
|
110
|
-
sproc =
|
113
|
+
sproc = spawn_subproc(cmd=[testfn])
|
111
114
|
shutil.copyfile(testfn, testfn + '-2')
|
112
115
|
safe_rmpath(testfn + '-2')
|
113
116
|
except (UnicodeEncodeError, OSError):
|
@@ -166,7 +169,7 @@ class TestFSAPIs(BaseUnicodeTest):
|
|
166
169
|
"-c",
|
167
170
|
"import time; [time.sleep(0.1) for x in range(100)]",
|
168
171
|
]
|
169
|
-
subp = self.
|
172
|
+
subp = self.spawn_subproc(cmd)
|
170
173
|
p = psutil.Process(subp.pid)
|
171
174
|
exe = p.exe()
|
172
175
|
assert isinstance(exe, str)
|
@@ -179,7 +182,7 @@ class TestFSAPIs(BaseUnicodeTest):
|
|
179
182
|
"-c",
|
180
183
|
"import time; [time.sleep(0.1) for x in range(100)]",
|
181
184
|
]
|
182
|
-
subp = self.
|
185
|
+
subp = self.spawn_subproc(cmd)
|
183
186
|
name = psutil.Process(subp.pid).name()
|
184
187
|
assert isinstance(name, str)
|
185
188
|
if self.expect_exact_path_match():
|
@@ -191,7 +194,7 @@ class TestFSAPIs(BaseUnicodeTest):
|
|
191
194
|
"-c",
|
192
195
|
"import time; [time.sleep(0.1) for x in range(100)]",
|
193
196
|
]
|
194
|
-
subp = self.
|
197
|
+
subp = self.spawn_subproc(cmd)
|
195
198
|
p = psutil.Process(subp.pid)
|
196
199
|
cmdline = p.cmdline()
|
197
200
|
for part in cmdline:
|
@@ -211,6 +214,9 @@ class TestFSAPIs(BaseUnicodeTest):
|
|
211
214
|
assert cwd == dname
|
212
215
|
|
213
216
|
@pytest.mark.skipif(PYPY and WINDOWS, reason="fails on PYPY + WINDOWS")
|
217
|
+
@pytest.mark.skipif(
|
218
|
+
NETBSD or OPENBSD, reason="broken on NETBSD or OPENBSD"
|
219
|
+
)
|
214
220
|
def test_proc_open_files(self):
|
215
221
|
p = psutil.Process()
|
216
222
|
start = set(p.open_files())
|
@@ -231,6 +237,8 @@ class TestFSAPIs(BaseUnicodeTest):
|
|
231
237
|
with closing(sock):
|
232
238
|
conn = psutil.Process().net_connections('unix')[0]
|
233
239
|
assert isinstance(conn.laddr, str)
|
240
|
+
if not conn.laddr and MACOS and CI_TESTING:
|
241
|
+
raise pytest.skip("unreliable on OSX")
|
234
242
|
assert conn.laddr == name
|
235
243
|
|
236
244
|
@pytest.mark.skipif(not POSIX, reason="POSIX only")
|
@@ -260,7 +268,6 @@ class TestFSAPIs(BaseUnicodeTest):
|
|
260
268
|
psutil.disk_usage(dname)
|
261
269
|
|
262
270
|
@pytest.mark.skipif(not HAS_MEMORY_MAPS, reason="not supported")
|
263
|
-
@pytest.mark.skipif(PYPY, reason="unstable on PYPY")
|
264
271
|
def test_memory_maps(self):
|
265
272
|
with copyload_shared_lib(suffix=self.funky_suffix) as funky_path:
|
266
273
|
|
@@ -284,7 +291,7 @@ class TestFSAPIsWithInvalidPath(TestFSAPIs):
|
|
284
291
|
funky_suffix = INVALID_UNICODE_SUFFIX
|
285
292
|
|
286
293
|
def expect_exact_path_match(self):
|
287
|
-
return
|
294
|
+
return not MACOS
|
288
295
|
|
289
296
|
|
290
297
|
# ===================================================================
|
@@ -304,7 +311,7 @@ class TestNonFSAPIS(BaseUnicodeTest):
|
|
304
311
|
# with fs paths.
|
305
312
|
env = os.environ.copy()
|
306
313
|
env['FUNNY_ARG'] = self.funky_suffix
|
307
|
-
sproc = self.
|
314
|
+
sproc = self.spawn_subproc(env=env)
|
308
315
|
p = psutil.Process(sproc.pid)
|
309
316
|
env = p.environ()
|
310
317
|
for k, v in env.items():
|
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
"""Windows specific tests."""
|
8
8
|
|
9
|
+
import ctypes
|
9
10
|
import datetime
|
10
11
|
import glob
|
11
12
|
import os
|
@@ -31,10 +32,9 @@ from psutil.tests import PsutilTestCase
|
|
31
32
|
from psutil.tests import pytest
|
32
33
|
from psutil.tests import retry_on_failure
|
33
34
|
from psutil.tests import sh
|
34
|
-
from psutil.tests import
|
35
|
+
from psutil.tests import spawn_subproc
|
35
36
|
from psutil.tests import terminate
|
36
37
|
|
37
|
-
|
38
38
|
if WINDOWS and not PYPY:
|
39
39
|
with warnings.catch_warnings():
|
40
40
|
warnings.simplefilter("ignore")
|
@@ -141,7 +141,7 @@ class TestSystemAPIs(WindowsTestCase):
|
|
141
141
|
if "pseudo-interface" in nic.replace(' ', '-').lower():
|
142
142
|
continue
|
143
143
|
if nic not in out:
|
144
|
-
raise
|
144
|
+
raise pytest.fail(
|
145
145
|
f"{nic!r} nic wasn't found in 'ipconfig /all' output"
|
146
146
|
)
|
147
147
|
|
@@ -222,10 +222,12 @@ class TestSystemAPIs(WindowsTestCase):
|
|
222
222
|
assert usage.free == wmi_free
|
223
223
|
# 10 MB tolerance
|
224
224
|
if abs(usage.free - wmi_free) > 10 * 1024 * 1024:
|
225
|
-
raise
|
225
|
+
raise pytest.fail(
|
226
|
+
f"psutil={usage.free}, wmi={wmi_free}"
|
227
|
+
)
|
226
228
|
break
|
227
229
|
else:
|
228
|
-
raise
|
230
|
+
raise pytest.fail(f"can't find partition {ps_part!r}")
|
229
231
|
|
230
232
|
@retry_on_failure()
|
231
233
|
def test_disk_usage(self):
|
@@ -253,6 +255,38 @@ class TestSystemAPIs(WindowsTestCase):
|
|
253
255
|
]
|
254
256
|
assert sys_value == psutil_value
|
255
257
|
|
258
|
+
def test_convert_dos_path_drive(self):
|
259
|
+
winpath = 'C:\\Windows\\Temp'
|
260
|
+
driveletter = 'C:'
|
261
|
+
# Mocked NT device path for C:
|
262
|
+
devicepath = '\\Device\\HarddiskVolume1'
|
263
|
+
|
264
|
+
# Path returned by RtlDosPathNameToNtPathName
|
265
|
+
ntpath1 = '\\??\\C:\\Windows\\Temp'
|
266
|
+
# Mocked normalized NT path
|
267
|
+
ntpath2 = '\\Device\\HarddiskVolume1\\Windows\\Temp'
|
268
|
+
|
269
|
+
devices = {devicepath: driveletter}
|
270
|
+
|
271
|
+
with mock.patch(
|
272
|
+
'psutil._pswindows.cext.QueryDosDevice', side_effect=devices.get
|
273
|
+
) as m:
|
274
|
+
assert psutil._pswindows.convert_dos_path(ntpath1) == winpath
|
275
|
+
assert psutil._pswindows.convert_dos_path(ntpath2) == winpath
|
276
|
+
assert m.called
|
277
|
+
|
278
|
+
def test_convert_dos_path_unc(self):
|
279
|
+
# UNC path
|
280
|
+
winpath = '\\\\localhost\\C$\\Windows\\Temp'
|
281
|
+
# Path returned by RtlDosPathNameToNtPathName
|
282
|
+
ntpath1 = '\\??\\UNC\\localhost\\C$\\Windows\\Temp'
|
283
|
+
# Normalized NT path
|
284
|
+
ntpath2 = '\\Device\\Mup\\localhost\\C$\\Windows\\Temp'
|
285
|
+
|
286
|
+
assert psutil._pswindows.convert_dos_path(winpath) == winpath
|
287
|
+
assert psutil._pswindows.convert_dos_path(ntpath1) == winpath
|
288
|
+
assert psutil._pswindows.convert_dos_path(ntpath2) == winpath
|
289
|
+
|
256
290
|
def test_net_if_stats(self):
|
257
291
|
ps_names = set(cext.net_if_stats())
|
258
292
|
wmi_adapters = wmi.WMI().Win32_NetworkAdapter()
|
@@ -272,18 +306,14 @@ class TestSystemAPIs(WindowsTestCase):
|
|
272
306
|
)
|
273
307
|
psutil_dt = datetime.datetime.fromtimestamp(psutil.boot_time())
|
274
308
|
diff = abs((wmi_btime_dt - psutil_dt).total_seconds())
|
275
|
-
assert diff <= 5
|
309
|
+
assert diff <= 5, (psutil_dt, wmi_btime_dt)
|
276
310
|
|
277
|
-
def
|
278
|
-
#
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
with mock.patch('psutil._pswindows.cext.boot_time', return_value=6):
|
284
|
-
assert psutil.boot_time() == 5
|
285
|
-
with mock.patch('psutil._pswindows.cext.boot_time', return_value=333):
|
286
|
-
assert psutil.boot_time() == 333
|
311
|
+
def test_uptime(self):
|
312
|
+
# ...against GetTickCount64() (Windows < 7, does not include
|
313
|
+
# time spent during suspend / hybernate).
|
314
|
+
ms = ctypes.windll.kernel32.GetTickCount64()
|
315
|
+
secs = ms / 1000.0
|
316
|
+
assert abs(cext.uptime() - secs) < 0.5
|
287
317
|
|
288
318
|
|
289
319
|
# ===================================================================
|
@@ -364,7 +394,7 @@ class TestSensorsBattery(WindowsTestCase):
|
|
364
394
|
class TestProcess(WindowsTestCase):
|
365
395
|
@classmethod
|
366
396
|
def setUpClass(cls):
|
367
|
-
cls.pid =
|
397
|
+
cls.pid = spawn_subproc().pid
|
368
398
|
|
369
399
|
@classmethod
|
370
400
|
def tearDownClass(cls):
|
@@ -409,7 +439,7 @@ class TestProcess(WindowsTestCase):
|
|
409
439
|
assert p.num_handles() == before
|
410
440
|
|
411
441
|
def test_ctrl_signals(self):
|
412
|
-
p = psutil.Process(self.
|
442
|
+
p = psutil.Process(self.spawn_subproc().pid)
|
413
443
|
p.send_signal(signal.CTRL_C_EVENT)
|
414
444
|
p.send_signal(signal.CTRL_BREAK_EVENT)
|
415
445
|
p.kill()
|
@@ -442,17 +472,14 @@ class TestProcess(WindowsTestCase):
|
|
442
472
|
# XXX - occasional failures
|
443
473
|
|
444
474
|
# def test_cpu_times(self):
|
445
|
-
# handle = win32api.OpenProcess(
|
446
|
-
#
|
475
|
+
# handle = win32api.OpenProcess(
|
476
|
+
# win32con.PROCESS_QUERY_INFORMATION, win32con.FALSE, os.getpid()
|
477
|
+
# )
|
447
478
|
# self.addCleanup(win32api.CloseHandle, handle)
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
#
|
452
|
-
# delta=0.2)
|
453
|
-
# self.assertAlmostEqual(
|
454
|
-
# psutil_value.user, sys_value['KernelTime'] / 10000000.0,
|
455
|
-
# delta=0.2)
|
479
|
+
# a = psutil.Process().cpu_times()
|
480
|
+
# b = win32process.GetProcessTimes(handle)
|
481
|
+
# assert abs(a.user - b['UserTime'] / 10000000.0) < 0.2
|
482
|
+
# assert abs(a.user - b['KernelTime'] / 10000000.0) < 0.2
|
456
483
|
|
457
484
|
def test_nice(self):
|
458
485
|
handle = win32api.OpenProcess(
|
@@ -572,7 +599,7 @@ class TestProcessWMI(WindowsTestCase):
|
|
572
599
|
|
573
600
|
@classmethod
|
574
601
|
def setUpClass(cls):
|
575
|
-
cls.pid =
|
602
|
+
cls.pid = spawn_subproc().pid
|
576
603
|
|
577
604
|
@classmethod
|
578
605
|
def tearDownClass(cls):
|
@@ -624,7 +651,7 @@ class TestProcessWMI(WindowsTestCase):
|
|
624
651
|
# returned instead.
|
625
652
|
wmi_usage = int(w.PageFileUsage)
|
626
653
|
if vms not in {wmi_usage, wmi_usage * 1024}:
|
627
|
-
raise
|
654
|
+
raise pytest.fail(f"wmi={wmi_usage}, psutil={vms}")
|
628
655
|
|
629
656
|
def test_create_time(self):
|
630
657
|
w = wmi.WMI().Win32_Process(ProcessId=self.pid)[0]
|
@@ -652,7 +679,7 @@ class TestDualProcessImplementation(PsutilTestCase):
|
|
652
679
|
|
653
680
|
@classmethod
|
654
681
|
def setUpClass(cls):
|
655
|
-
cls.pid =
|
682
|
+
cls.pid = spawn_subproc().pid
|
656
683
|
|
657
684
|
@classmethod
|
658
685
|
def tearDownClass(cls):
|
@@ -772,10 +799,10 @@ class RemoteProcessTestCase(PsutilTestCase):
|
|
772
799
|
|
773
800
|
env = os.environ.copy()
|
774
801
|
env["THINK_OF_A_NUMBER"] = str(os.getpid())
|
775
|
-
self.proc32 = self.
|
802
|
+
self.proc32 = self.spawn_subproc(
|
776
803
|
[self.python32] + self.test_args, env=env, stdin=subprocess.PIPE
|
777
804
|
)
|
778
|
-
self.proc64 = self.
|
805
|
+
self.proc64 = self.spawn_subproc(
|
779
806
|
[self.python64] + self.test_args, env=env, stdin=subprocess.PIPE
|
780
807
|
)
|
781
808
|
|
@@ -844,6 +871,11 @@ class TestServices(PsutilTestCase):
|
|
844
871
|
"stopped",
|
845
872
|
}
|
846
873
|
for serv in psutil.win_service_iter():
|
874
|
+
if serv.name() == "WaaSMedicSvc":
|
875
|
+
# known issue in Windows 11 reading the description
|
876
|
+
# https://learn.microsoft.com/en-us/answers/questions/1320388/in-windows-11-version-22h2-there-it-shows-(failed
|
877
|
+
# https://github.com/giampaolo/psutil/issues/2383
|
878
|
+
continue
|
847
879
|
data = serv.as_dict()
|
848
880
|
assert isinstance(data['name'], str)
|
849
881
|
assert data['name'].strip()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: py2docfx
|
3
|
-
Version: 0.1.20.
|
3
|
+
Version: 0.1.20.dev2246325
|
4
4
|
Summary: A package built based on Sphinx which download source code package and generate yaml files supported by docfx.
|
5
5
|
Author: Microsoft Corporation
|
6
6
|
License: MIT License
|