py2docfx 0.1.11rc1981066__py3-none-any.whl → 0.1.11rc1997820__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/__main__.py +24 -15
- py2docfx/convert_prepare/environment.py +13 -10
- py2docfx/convert_prepare/generate_document.py +6 -6
- py2docfx/convert_prepare/get_source.py +7 -7
- py2docfx/convert_prepare/git.py +10 -13
- py2docfx/convert_prepare/install_package.py +2 -2
- py2docfx/convert_prepare/pack.py +7 -10
- py2docfx/convert_prepare/package_info.py +3 -3
- py2docfx/convert_prepare/pip_utils.py +12 -14
- py2docfx/convert_prepare/post_process/merge_toc.py +3 -2
- py2docfx/convert_prepare/sphinx_caller.py +34 -12
- py2docfx/convert_prepare/tests/test_environment.py +0 -3
- py2docfx/convert_prepare/tests/test_generate_document.py +4 -2
- py2docfx/convert_prepare/tests/test_get_source.py +22 -14
- py2docfx/convert_prepare/tests/test_pack.py +6 -3
- py2docfx/convert_prepare/tests/test_params.py +0 -1
- py2docfx/convert_prepare/tests/test_sphinx_caller.py +10 -8
- py2docfx/convert_prepare/tests/test_subpackage.py +1 -0
- py2docfx/docfx_yaml/build_finished.py +1 -1
- py2docfx/docfx_yaml/logger.py +56 -55
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/authorization_code.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azd_cli.py +20 -14
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_arc.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_cli.py +36 -14
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_powershell.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/chained.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +4 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/imds.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/managed_identity.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/__init__.py +2 -0
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/auth_code_redirect_handler.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/decorators.py +15 -7
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/interactive.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/managed_identity_client.py +0 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_client.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_managed_identity_client.py +2 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/shared_token_cache.py +3 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/utils.py +17 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +14 -11
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +30 -12
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/imds.py +3 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/managed_identity.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_internal/decorators.py +15 -7
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_internal/managed_identity_client.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/google/api/annotations_pb2.py +7 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/auth_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/backend_pb2.py +14 -7
- py2docfx/venv/venv1/Lib/site-packages/google/api/billing_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/client_pb2.py +47 -38
- py2docfx/venv/venv1/Lib/site-packages/google/api/config_change_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/consumer_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/context_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/control_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/distribution_pb2.py +7 -5
- py2docfx/venv/venv1/Lib/site-packages/google/api/documentation_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/endpoint_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/error_reason_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/field_behavior_pb2.py +8 -6
- py2docfx/venv/venv1/Lib/site-packages/google/api/field_info_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/http_pb2.py +7 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/httpbody_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/label_pb2.py +7 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/launch_stage_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/log_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/logging_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/metric_pb2.py +12 -9
- py2docfx/venv/venv1/Lib/site-packages/google/api/monitored_resource_pb2.py +15 -10
- py2docfx/venv/venv1/Lib/site-packages/google/api/monitoring_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/policy_pb2.py +7 -5
- py2docfx/venv/venv1/Lib/site-packages/google/api/quota_pb2.py +10 -7
- py2docfx/venv/venv1/Lib/site-packages/google/api/resource_pb2.py +7 -5
- py2docfx/venv/venv1/Lib/site-packages/google/api/routing_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/service_pb2.py +15 -12
- py2docfx/venv/venv1/Lib/site-packages/google/api/source_info_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/api/system_parameter_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/usage_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api/visibility_pb2.py +7 -5
- py2docfx/venv/venv1/Lib/site-packages/google/cloud/extended_operations_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/cloud/location/locations_pb2.py +18 -13
- py2docfx/venv/venv1/Lib/site-packages/google/gapic/metadata/gapic_metadata_pb2.py +31 -26
- py2docfx/venv/venv1/Lib/site-packages/google/logging/type/http_request_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/logging/type/log_severity_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_grpc.py +2 -1
- py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_grpc_pb2.py +11 -10
- py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_pb2.py +20 -17
- py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_pb2_grpc.py +1 -2
- py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_proto.py +2 -1
- py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_proto_pb2.py +22 -19
- py2docfx/venv/venv1/Lib/site-packages/google/rpc/code_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/rpc/context/attribute_context_pb2.py +20 -16
- py2docfx/venv/venv1/Lib/site-packages/google/rpc/context/audit_context_pb2.py +7 -5
- py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.py +21 -19
- py2docfx/venv/venv1/Lib/site-packages/google/rpc/http_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/rpc/status_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/type/calendar_period_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/color_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/type/date_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/datetime_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/type/dayofweek_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/decimal_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/expr_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/fraction_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/interval_pb2.py +6 -4
- py2docfx/venv/venv1/Lib/site-packages/google/type/latlng_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/localized_text_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/money_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/month_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/phone_number_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/postal_address_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/quaternion_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/google/type/timeofday_pb2.py +6 -3
- py2docfx/venv/venv1/Lib/site-packages/psutil/__init__.py +122 -201
- py2docfx/venv/venv1/Lib/site-packages/psutil/_common.py +84 -128
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psaix.py +24 -38
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psbsd.py +44 -58
- py2docfx/venv/venv1/Lib/site-packages/psutil/_pslinux.py +170 -254
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psosx.py +8 -16
- py2docfx/venv/venv1/Lib/site-packages/psutil/_psposix.py +13 -49
- py2docfx/venv/venv1/Lib/site-packages/psutil/_pssunos.py +41 -60
- py2docfx/venv/venv1/Lib/site-packages/psutil/_pswindows.py +75 -145
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__init__.py +105 -193
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_aix.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_bsd.py +27 -26
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_connections.py +16 -17
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_contracts.py +5 -19
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_linux.py +153 -211
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_memleaks.py +0 -6
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_misc.py +22 -207
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_osx.py +9 -4
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_posix.py +8 -15
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process.py +104 -184
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process_all.py +28 -36
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_scripts.py +240 -0
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_sunos.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_system.py +44 -50
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_testutils.py +23 -33
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_unicode.py +8 -67
- py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_windows.py +32 -52
- {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/METADATA +1 -1
- {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/RECORD +145 -145
- py2docfx/venv/venv1/Lib/site-packages/psutil/_compat.py +0 -477
- {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.11rc1981066.dist-info → py2docfx-0.1.11rc1997820.dist-info}/top_level.txt +0 -0
@@ -14,7 +14,6 @@ PyPy appears to be completely unstable for this framework, probably
|
|
14
14
|
because of how its JIT handles memory, so tests are skipped.
|
15
15
|
"""
|
16
16
|
|
17
|
-
from __future__ import print_function
|
18
17
|
|
19
18
|
import functools
|
20
19
|
import os
|
@@ -28,8 +27,6 @@ from psutil import OPENBSD
|
|
28
27
|
from psutil import POSIX
|
29
28
|
from psutil import SUNOS
|
30
29
|
from psutil import WINDOWS
|
31
|
-
from psutil._compat import ProcessLookupError
|
32
|
-
from psutil._compat import super
|
33
30
|
from psutil.tests import HAS_CPU_AFFINITY
|
34
31
|
from psutil.tests import HAS_CPU_FREQ
|
35
32
|
from psutil.tests import HAS_ENVIRON
|
@@ -42,7 +39,6 @@ from psutil.tests import HAS_RLIMIT
|
|
42
39
|
from psutil.tests import HAS_SENSORS_BATTERY
|
43
40
|
from psutil.tests import HAS_SENSORS_FANS
|
44
41
|
from psutil.tests import HAS_SENSORS_TEMPERATURES
|
45
|
-
from psutil.tests import QEMU_USER
|
46
42
|
from psutil.tests import TestMemoryLeak
|
47
43
|
from psutil.tests import create_sockets
|
48
44
|
from psutil.tests import get_testfn
|
@@ -399,7 +395,6 @@ class TestModuleFunctionsLeaks(TestMemoryLeak):
|
|
399
395
|
times = FEW_TIMES if POSIX else self.times
|
400
396
|
self.execute(lambda: psutil.disk_usage('.'), times=times)
|
401
397
|
|
402
|
-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
|
403
398
|
def test_disk_partitions(self):
|
404
399
|
self.execute(psutil.disk_partitions)
|
405
400
|
|
@@ -437,7 +432,6 @@ class TestModuleFunctionsLeaks(TestMemoryLeak):
|
|
437
432
|
tolerance = 80 * 1024 if WINDOWS else self.tolerance
|
438
433
|
self.execute(psutil.net_if_addrs, tolerance=tolerance)
|
439
434
|
|
440
|
-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
|
441
435
|
def test_net_if_stats(self):
|
442
436
|
self.execute(psutil.net_if_stats)
|
443
437
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
|
4
3
|
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
|
5
4
|
# Use of this source code is governed by a BSD-style license that can be
|
@@ -7,19 +6,18 @@
|
|
7
6
|
|
8
7
|
"""Miscellaneous tests."""
|
9
8
|
|
10
|
-
import ast
|
11
9
|
import collections
|
12
|
-
import
|
10
|
+
import contextlib
|
11
|
+
import io
|
13
12
|
import json
|
14
13
|
import os
|
15
14
|
import pickle
|
16
15
|
import socket
|
17
|
-
import stat
|
18
16
|
import sys
|
17
|
+
from unittest import mock
|
19
18
|
|
20
19
|
import psutil
|
21
20
|
import psutil.tests
|
22
|
-
from psutil import POSIX
|
23
21
|
from psutil import WINDOWS
|
24
22
|
from psutil._common import bcat
|
25
23
|
from psutil._common import cat
|
@@ -30,26 +28,11 @@ from psutil._common import memoize_when_activated
|
|
30
28
|
from psutil._common import parse_environ_block
|
31
29
|
from psutil._common import supports_ipv6
|
32
30
|
from psutil._common import wrap_numbers
|
33
|
-
from psutil._compat import PY3
|
34
|
-
from psutil._compat import FileNotFoundError
|
35
|
-
from psutil._compat import redirect_stderr
|
36
|
-
from psutil.tests import CI_TESTING
|
37
|
-
from psutil.tests import HAS_BATTERY
|
38
|
-
from psutil.tests import HAS_MEMORY_MAPS
|
39
31
|
from psutil.tests import HAS_NET_IO_COUNTERS
|
40
|
-
from psutil.tests import HAS_SENSORS_BATTERY
|
41
|
-
from psutil.tests import HAS_SENSORS_FANS
|
42
|
-
from psutil.tests import HAS_SENSORS_TEMPERATURES
|
43
|
-
from psutil.tests import PYTHON_EXE
|
44
|
-
from psutil.tests import PYTHON_EXE_ENV
|
45
|
-
from psutil.tests import QEMU_USER
|
46
|
-
from psutil.tests import SCRIPTS_DIR
|
47
32
|
from psutil.tests import PsutilTestCase
|
48
|
-
from psutil.tests import mock
|
49
33
|
from psutil.tests import process_namespace
|
50
34
|
from psutil.tests import pytest
|
51
35
|
from psutil.tests import reload_module
|
52
|
-
from psutil.tests import sh
|
53
36
|
from psutil.tests import system_namespace
|
54
37
|
|
55
38
|
|
@@ -69,8 +52,8 @@ class TestSpecialMethods(PsutilTestCase):
|
|
69
52
|
p = psutil.Process(self.spawn_testproc().pid)
|
70
53
|
r = func(p)
|
71
54
|
assert "psutil.Process" in r
|
72
|
-
assert "pid
|
73
|
-
assert "name='
|
55
|
+
assert f"pid={p.pid}" in r
|
56
|
+
assert f"name='{p.name()}'" in r.replace("name=u'", "name='")
|
74
57
|
assert "status=" in r
|
75
58
|
assert "exitcode=" not in r
|
76
59
|
p.terminate()
|
@@ -86,7 +69,7 @@ class TestSpecialMethods(PsutilTestCase):
|
|
86
69
|
):
|
87
70
|
p = psutil.Process()
|
88
71
|
r = func(p)
|
89
|
-
assert "pid
|
72
|
+
assert f"pid={p.pid}" in r
|
90
73
|
assert "status='zombie'" in r
|
91
74
|
assert "name=" not in r
|
92
75
|
with mock.patch.object(
|
@@ -96,7 +79,7 @@ class TestSpecialMethods(PsutilTestCase):
|
|
96
79
|
):
|
97
80
|
p = psutil.Process()
|
98
81
|
r = func(p)
|
99
|
-
assert "pid
|
82
|
+
assert f"pid={p.pid}" in r
|
100
83
|
assert "terminated" in r
|
101
84
|
assert "name=" not in r
|
102
85
|
with mock.patch.object(
|
@@ -106,7 +89,7 @@ class TestSpecialMethods(PsutilTestCase):
|
|
106
89
|
):
|
107
90
|
p = psutil.Process()
|
108
91
|
r = func(p)
|
109
|
-
assert "pid
|
92
|
+
assert f"pid={p.pid}" in r
|
110
93
|
assert "name=" not in r
|
111
94
|
|
112
95
|
def test_process__str__(self):
|
@@ -116,7 +99,7 @@ class TestSpecialMethods(PsutilTestCase):
|
|
116
99
|
assert repr(psutil.Error()) == "psutil.Error()"
|
117
100
|
|
118
101
|
def test_error__str__(self):
|
119
|
-
assert str(psutil.Error()) == ""
|
102
|
+
assert str(psutil.Error()) == ""
|
120
103
|
|
121
104
|
def test_no_such_process__repr__(self):
|
122
105
|
assert (
|
@@ -202,7 +185,7 @@ class TestSpecialMethods(PsutilTestCase):
|
|
202
185
|
assert p1 != 'foo'
|
203
186
|
|
204
187
|
def test_process__hash__(self):
|
205
|
-
s =
|
188
|
+
s = {psutil.Process(), psutil.Process()}
|
206
189
|
assert len(s) == 1
|
207
190
|
|
208
191
|
|
@@ -217,7 +200,6 @@ class TestMisc(PsutilTestCase):
|
|
217
200
|
for name in dir_psutil:
|
218
201
|
if name in {
|
219
202
|
'debug',
|
220
|
-
'long',
|
221
203
|
'tests',
|
222
204
|
'test',
|
223
205
|
'PermissionError',
|
@@ -236,11 +218,11 @@ class TestMisc(PsutilTestCase):
|
|
236
218
|
fun.__doc__ is not None
|
237
219
|
and 'deprecated' not in fun.__doc__.lower()
|
238
220
|
):
|
239
|
-
raise self.fail(
|
221
|
+
raise self.fail(f"{name!r} not in psutil.__all__")
|
240
222
|
|
241
223
|
# Import 'star' will break if __all__ is inconsistent, see:
|
242
224
|
# https://github.com/giampaolo/psutil/issues/656
|
243
|
-
# Can't do `from psutil import *` as it won't work
|
225
|
+
# Can't do `from psutil import *` as it won't work
|
244
226
|
# so we simply iterate over __all__.
|
245
227
|
for name in psutil.__all__:
|
246
228
|
assert name in dir_psutil
|
@@ -286,9 +268,6 @@ class TestMisc(PsutilTestCase):
|
|
286
268
|
for fun, name in ns.iter(ns.getters):
|
287
269
|
if name in {"win_service_iter", "win_service_get"}:
|
288
270
|
continue
|
289
|
-
if QEMU_USER and name == "net_if_stats":
|
290
|
-
# OSError: [Errno 38] ioctl(SIOCETHTOOL) not implemented
|
291
|
-
continue
|
292
271
|
with self.subTest(name=name):
|
293
272
|
try:
|
294
273
|
ret = fun()
|
@@ -338,18 +317,6 @@ class TestMisc(PsutilTestCase):
|
|
338
317
|
assert b.pid == 4567
|
339
318
|
assert b.name == 'name'
|
340
319
|
|
341
|
-
# # XXX: https://github.com/pypa/setuptools/pull/2896
|
342
|
-
# @pytest.mark.skipif(APPVEYOR,
|
343
|
-
# reason="temporarily disabled due to setuptools bug"
|
344
|
-
# )
|
345
|
-
# def test_setup_script(self):
|
346
|
-
# setup_py = os.path.join(ROOT_DIR, 'setup.py')
|
347
|
-
# if CI_TESTING and not os.path.exists(setup_py):
|
348
|
-
# raise pytest.skip("can't find setup.py")
|
349
|
-
# module = import_module_by_path(setup_py)
|
350
|
-
# self.assertRaises(SystemExit, module.setup)
|
351
|
-
# self.assertEqual(module.get_version(), psutil.__version__)
|
352
|
-
|
353
320
|
def test_ad_on_process_creation(self):
|
354
321
|
# We are supposed to be able to instantiate Process also in case
|
355
322
|
# of zombie processes or access denied.
|
@@ -587,7 +554,7 @@ class TestCommonModule(PsutilTestCase):
|
|
587
554
|
|
588
555
|
supports_ipv6.cache_clear()
|
589
556
|
with mock.patch(
|
590
|
-
'psutil._common.socket.socket', side_effect=
|
557
|
+
'psutil._common.socket.socket', side_effect=OSError
|
591
558
|
) as s:
|
592
559
|
assert not supports_ipv6()
|
593
560
|
assert s.called
|
@@ -609,7 +576,7 @@ class TestCommonModule(PsutilTestCase):
|
|
609
576
|
supports_ipv6.cache_clear()
|
610
577
|
assert s.called
|
611
578
|
else:
|
612
|
-
with pytest.raises(
|
579
|
+
with pytest.raises(OSError):
|
613
580
|
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
614
581
|
try:
|
615
582
|
sock.bind(("::1", 0))
|
@@ -620,31 +587,19 @@ class TestCommonModule(PsutilTestCase):
|
|
620
587
|
this_file = os.path.abspath(__file__)
|
621
588
|
assert isfile_strict(this_file)
|
622
589
|
assert not isfile_strict(os.path.dirname(this_file))
|
623
|
-
with mock.patch(
|
624
|
-
'psutil._common.os.stat', side_effect=OSError(errno.EPERM, "foo")
|
625
|
-
):
|
626
|
-
with pytest.raises(OSError):
|
627
|
-
isfile_strict(this_file)
|
628
|
-
with mock.patch(
|
629
|
-
'psutil._common.os.stat', side_effect=OSError(errno.EACCES, "foo")
|
630
|
-
):
|
590
|
+
with mock.patch('psutil._common.os.stat', side_effect=PermissionError):
|
631
591
|
with pytest.raises(OSError):
|
632
592
|
isfile_strict(this_file)
|
633
593
|
with mock.patch(
|
634
|
-
'psutil._common.os.stat', side_effect=
|
594
|
+
'psutil._common.os.stat', side_effect=FileNotFoundError
|
635
595
|
):
|
636
596
|
assert not isfile_strict(this_file)
|
637
597
|
with mock.patch('psutil._common.stat.S_ISREG', return_value=False):
|
638
598
|
assert not isfile_strict(this_file)
|
639
599
|
|
640
600
|
def test_debug(self):
|
641
|
-
if PY3:
|
642
|
-
from io import StringIO
|
643
|
-
else:
|
644
|
-
from StringIO import StringIO
|
645
|
-
|
646
601
|
with mock.patch.object(psutil._common, "PSUTIL_DEBUG", True):
|
647
|
-
with redirect_stderr(StringIO()) as f:
|
602
|
+
with contextlib.redirect_stderr(io.StringIO()) as f:
|
648
603
|
debug("hello")
|
649
604
|
sys.stderr.flush()
|
650
605
|
msg = f.getvalue()
|
@@ -654,7 +609,7 @@ class TestCommonModule(PsutilTestCase):
|
|
654
609
|
|
655
610
|
# supposed to use repr(exc)
|
656
611
|
with mock.patch.object(psutil._common, "PSUTIL_DEBUG", True):
|
657
|
-
with redirect_stderr(StringIO()) as f:
|
612
|
+
with contextlib.redirect_stderr(io.StringIO()) as f:
|
658
613
|
debug(ValueError("this is an error"))
|
659
614
|
msg = f.getvalue()
|
660
615
|
assert "ignoring ValueError" in msg
|
@@ -662,7 +617,7 @@ class TestCommonModule(PsutilTestCase):
|
|
662
617
|
|
663
618
|
# supposed to use str(exc), because of extra info about file name
|
664
619
|
with mock.patch.object(psutil._common, "PSUTIL_DEBUG", True):
|
665
|
-
with redirect_stderr(StringIO()) as f:
|
620
|
+
with contextlib.redirect_stderr(io.StringIO()) as f:
|
666
621
|
exc = OSError(2, "no such file")
|
667
622
|
exc.filename = "/foo"
|
668
623
|
debug(exc)
|
@@ -838,7 +793,7 @@ class TestWrapNumbers(PsutilTestCase):
|
|
838
793
|
assert cache[1] == {
|
839
794
|
'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 100}
|
840
795
|
}
|
841
|
-
assert cache[2] == {'disk_io': {'disk1':
|
796
|
+
assert cache[2] == {'disk_io': {'disk1': {('disk1', 2)}}}
|
842
797
|
|
843
798
|
def check_cache_info():
|
844
799
|
cache = wrap_numbers.cache_info()
|
@@ -849,7 +804,7 @@ class TestWrapNumbers(PsutilTestCase):
|
|
849
804
|
('disk1', 2): 100,
|
850
805
|
}
|
851
806
|
}
|
852
|
-
assert cache[2] == {'disk_io': {'disk1':
|
807
|
+
assert cache[2] == {'disk_io': {'disk1': {('disk1', 2)}}}
|
853
808
|
|
854
809
|
# then it remains the same
|
855
810
|
input = {'disk1': nt(100, 100, 10)}
|
@@ -873,7 +828,7 @@ class TestWrapNumbers(PsutilTestCase):
|
|
873
828
|
assert cache[1] == {
|
874
829
|
'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 190}
|
875
830
|
}
|
876
|
-
assert cache[2] == {'disk_io': {'disk1':
|
831
|
+
assert cache[2] == {'disk_io': {'disk1': {('disk1', 2)}}}
|
877
832
|
|
878
833
|
def test_cache_changing_keys(self):
|
879
834
|
input = {'disk1': nt(5, 5, 5)}
|
@@ -916,143 +871,3 @@ class TestWrapNumbers(PsutilTestCase):
|
|
916
871
|
psutil.net_io_counters.cache_clear()
|
917
872
|
caches = wrap_numbers.cache_info()
|
918
873
|
assert caches == ({}, {}, {})
|
919
|
-
|
920
|
-
|
921
|
-
# ===================================================================
|
922
|
-
# --- Example script tests
|
923
|
-
# ===================================================================
|
924
|
-
|
925
|
-
|
926
|
-
@pytest.mark.skipif(
|
927
|
-
not os.path.exists(SCRIPTS_DIR), reason="can't locate scripts directory"
|
928
|
-
)
|
929
|
-
class TestScripts(PsutilTestCase):
|
930
|
-
"""Tests for scripts in the "scripts" directory."""
|
931
|
-
|
932
|
-
@staticmethod
|
933
|
-
def assert_stdout(exe, *args, **kwargs):
|
934
|
-
kwargs.setdefault("env", PYTHON_EXE_ENV)
|
935
|
-
exe = '%s' % os.path.join(SCRIPTS_DIR, exe)
|
936
|
-
cmd = [PYTHON_EXE, exe]
|
937
|
-
for arg in args:
|
938
|
-
cmd.append(arg)
|
939
|
-
try:
|
940
|
-
out = sh(cmd, **kwargs).strip()
|
941
|
-
except RuntimeError as err:
|
942
|
-
if 'AccessDenied' in str(err):
|
943
|
-
return str(err)
|
944
|
-
else:
|
945
|
-
raise
|
946
|
-
assert out, out
|
947
|
-
return out
|
948
|
-
|
949
|
-
@staticmethod
|
950
|
-
def assert_syntax(exe):
|
951
|
-
exe = os.path.join(SCRIPTS_DIR, exe)
|
952
|
-
with open(exe, encoding="utf8") if PY3 else open(exe) as f:
|
953
|
-
src = f.read()
|
954
|
-
ast.parse(src)
|
955
|
-
|
956
|
-
def test_coverage(self):
|
957
|
-
# make sure all example scripts have a test method defined
|
958
|
-
meths = dir(self)
|
959
|
-
for name in os.listdir(SCRIPTS_DIR):
|
960
|
-
if name.endswith('.py'):
|
961
|
-
if 'test_' + os.path.splitext(name)[0] not in meths:
|
962
|
-
# self.assert_stdout(name)
|
963
|
-
raise self.fail(
|
964
|
-
'no test defined for %r script'
|
965
|
-
% os.path.join(SCRIPTS_DIR, name)
|
966
|
-
)
|
967
|
-
|
968
|
-
@pytest.mark.skipif(not POSIX, reason="POSIX only")
|
969
|
-
def test_executable(self):
|
970
|
-
for root, dirs, files in os.walk(SCRIPTS_DIR):
|
971
|
-
for file in files:
|
972
|
-
if file.endswith('.py'):
|
973
|
-
path = os.path.join(root, file)
|
974
|
-
if not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]:
|
975
|
-
raise self.fail('%r is not executable' % path)
|
976
|
-
|
977
|
-
def test_disk_usage(self):
|
978
|
-
self.assert_stdout('disk_usage.py')
|
979
|
-
|
980
|
-
def test_free(self):
|
981
|
-
self.assert_stdout('free.py')
|
982
|
-
|
983
|
-
def test_meminfo(self):
|
984
|
-
self.assert_stdout('meminfo.py')
|
985
|
-
|
986
|
-
def test_procinfo(self):
|
987
|
-
self.assert_stdout('procinfo.py', str(os.getpid()))
|
988
|
-
|
989
|
-
@pytest.mark.skipif(CI_TESTING and not psutil.users(), reason="no users")
|
990
|
-
def test_who(self):
|
991
|
-
self.assert_stdout('who.py')
|
992
|
-
|
993
|
-
def test_ps(self):
|
994
|
-
self.assert_stdout('ps.py')
|
995
|
-
|
996
|
-
def test_pstree(self):
|
997
|
-
self.assert_stdout('pstree.py')
|
998
|
-
|
999
|
-
def test_netstat(self):
|
1000
|
-
self.assert_stdout('netstat.py')
|
1001
|
-
|
1002
|
-
@pytest.mark.skipif(QEMU_USER, reason="QEMU user not supported")
|
1003
|
-
def test_ifconfig(self):
|
1004
|
-
self.assert_stdout('ifconfig.py')
|
1005
|
-
|
1006
|
-
@pytest.mark.skipif(not HAS_MEMORY_MAPS, reason="not supported")
|
1007
|
-
def test_pmap(self):
|
1008
|
-
self.assert_stdout('pmap.py', str(os.getpid()))
|
1009
|
-
|
1010
|
-
def test_procsmem(self):
|
1011
|
-
if 'uss' not in psutil.Process().memory_full_info()._fields:
|
1012
|
-
raise pytest.skip("not supported")
|
1013
|
-
self.assert_stdout('procsmem.py')
|
1014
|
-
|
1015
|
-
def test_killall(self):
|
1016
|
-
self.assert_syntax('killall.py')
|
1017
|
-
|
1018
|
-
def test_nettop(self):
|
1019
|
-
self.assert_syntax('nettop.py')
|
1020
|
-
|
1021
|
-
def test_top(self):
|
1022
|
-
self.assert_syntax('top.py')
|
1023
|
-
|
1024
|
-
def test_iotop(self):
|
1025
|
-
self.assert_syntax('iotop.py')
|
1026
|
-
|
1027
|
-
def test_pidof(self):
|
1028
|
-
output = self.assert_stdout('pidof.py', psutil.Process().name())
|
1029
|
-
assert str(os.getpid()) in output
|
1030
|
-
|
1031
|
-
@pytest.mark.skipif(not WINDOWS, reason="WINDOWS only")
|
1032
|
-
def test_winservices(self):
|
1033
|
-
self.assert_stdout('winservices.py')
|
1034
|
-
|
1035
|
-
def test_cpu_distribution(self):
|
1036
|
-
self.assert_syntax('cpu_distribution.py')
|
1037
|
-
|
1038
|
-
@pytest.mark.skipif(not HAS_SENSORS_TEMPERATURES, reason="not supported")
|
1039
|
-
def test_temperatures(self):
|
1040
|
-
if not psutil.sensors_temperatures():
|
1041
|
-
raise pytest.skip("no temperatures")
|
1042
|
-
self.assert_stdout('temperatures.py')
|
1043
|
-
|
1044
|
-
@pytest.mark.skipif(not HAS_SENSORS_FANS, reason="not supported")
|
1045
|
-
def test_fans(self):
|
1046
|
-
if not psutil.sensors_fans():
|
1047
|
-
raise pytest.skip("no fans")
|
1048
|
-
self.assert_stdout('fans.py')
|
1049
|
-
|
1050
|
-
@pytest.mark.skipif(not HAS_SENSORS_BATTERY, reason="not supported")
|
1051
|
-
@pytest.mark.skipif(not HAS_BATTERY, reason="no battery")
|
1052
|
-
def test_battery(self):
|
1053
|
-
self.assert_stdout('battery.py')
|
1054
|
-
|
1055
|
-
@pytest.mark.skipif(not HAS_SENSORS_BATTERY, reason="not supported")
|
1056
|
-
@pytest.mark.skipif(not HAS_BATTERY, reason="no battery")
|
1057
|
-
def test_sensors(self):
|
1058
|
-
self.assert_stdout('sensors.py')
|
@@ -13,6 +13,7 @@ import time
|
|
13
13
|
import psutil
|
14
14
|
from psutil import MACOS
|
15
15
|
from psutil import POSIX
|
16
|
+
from psutil.tests import CI_TESTING
|
16
17
|
from psutil.tests import HAS_BATTERY
|
17
18
|
from psutil.tests import TOLERANCE_DISK_USAGE
|
18
19
|
from psutil.tests import TOLERANCE_SYS_MEM
|
@@ -62,7 +63,7 @@ class TestProcess(PsutilTestCase):
|
|
62
63
|
terminate(cls.pid)
|
63
64
|
|
64
65
|
def test_process_create_time(self):
|
65
|
-
output = sh("ps -o lstart -p
|
66
|
+
output = sh(f"ps -o lstart -p {self.pid}")
|
66
67
|
start_ps = output.replace('STARTED', '').strip()
|
67
68
|
hhmmss = start_ps.split(' ')[-2]
|
68
69
|
year = start_ps.split(' ')[-1]
|
@@ -83,7 +84,7 @@ class TestSystemAPIs(PsutilTestCase):
|
|
83
84
|
# test psutil.disk_usage() and psutil.disk_partitions()
|
84
85
|
# against "df -a"
|
85
86
|
def df(path):
|
86
|
-
out = sh('df -k "
|
87
|
+
out = sh(f'df -k "{path}"').strip()
|
87
88
|
lines = out.split('\n')
|
88
89
|
lines.pop(0)
|
89
90
|
line = lines.pop(0)
|
@@ -129,6 +130,10 @@ class TestSystemAPIs(PsutilTestCase):
|
|
129
130
|
sysctl_hwphymem = sysctl('sysctl hw.memsize')
|
130
131
|
assert sysctl_hwphymem == psutil.virtual_memory().total
|
131
132
|
|
133
|
+
@pytest.mark.skipif(
|
134
|
+
CI_TESTING and MACOS and platform.machine() == 'arm64',
|
135
|
+
reason="skipped on MACOS + ARM64 + CI_TESTING",
|
136
|
+
)
|
132
137
|
@retry_on_failure()
|
133
138
|
def test_vmem_free(self):
|
134
139
|
vmstat_val = vm_stat("free")
|
@@ -172,7 +177,7 @@ class TestSystemAPIs(PsutilTestCase):
|
|
172
177
|
def test_net_if_stats(self):
|
173
178
|
for name, stats in psutil.net_if_stats().items():
|
174
179
|
try:
|
175
|
-
out = sh("ifconfig
|
180
|
+
out = sh(f"ifconfig {name}")
|
176
181
|
except RuntimeError:
|
177
182
|
pass
|
178
183
|
else:
|
@@ -185,7 +190,7 @@ class TestSystemAPIs(PsutilTestCase):
|
|
185
190
|
def test_sensors_battery(self):
|
186
191
|
out = sh("pmset -g batt")
|
187
192
|
percent = re.search(r"(\d+)%", out).group(1)
|
188
|
-
drawing_from = re.search("Now drawing from '([^']+)'", out).group(1)
|
193
|
+
drawing_from = re.search(r"Now drawing from '([^']+)'", out).group(1)
|
189
194
|
power_plugged = drawing_from == "AC Power"
|
190
195
|
psutil_result = psutil.sensors_battery()
|
191
196
|
assert psutil_result.power_plugged == power_plugged
|
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
|
4
3
|
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
|
5
4
|
# Use of this source code is governed by a BSD-style license that can be
|
@@ -11,8 +10,10 @@ import datetime
|
|
11
10
|
import errno
|
12
11
|
import os
|
13
12
|
import re
|
13
|
+
import shutil
|
14
14
|
import subprocess
|
15
15
|
import time
|
16
|
+
from unittest import mock
|
16
17
|
|
17
18
|
import psutil
|
18
19
|
from psutil import AIX
|
@@ -25,16 +26,13 @@ from psutil import SUNOS
|
|
25
26
|
from psutil.tests import AARCH64
|
26
27
|
from psutil.tests import HAS_NET_IO_COUNTERS
|
27
28
|
from psutil.tests import PYTHON_EXE
|
28
|
-
from psutil.tests import QEMU_USER
|
29
29
|
from psutil.tests import PsutilTestCase
|
30
|
-
from psutil.tests import mock
|
31
30
|
from psutil.tests import pytest
|
32
31
|
from psutil.tests import retry_on_failure
|
33
32
|
from psutil.tests import sh
|
34
33
|
from psutil.tests import skip_on_access_denied
|
35
34
|
from psutil.tests import spawn_testproc
|
36
35
|
from psutil.tests import terminate
|
37
|
-
from psutil.tests import which
|
38
36
|
|
39
37
|
|
40
38
|
if POSIX:
|
@@ -104,9 +102,6 @@ def ps_name(pid):
|
|
104
102
|
if SUNOS:
|
105
103
|
field = "comm"
|
106
104
|
command = ps(field, pid).split()
|
107
|
-
if QEMU_USER:
|
108
|
-
assert "/bin/qemu-" in command[0]
|
109
|
-
return command[1]
|
110
105
|
return command[0]
|
111
106
|
|
112
107
|
|
@@ -136,7 +131,7 @@ def ps_vsz(pid):
|
|
136
131
|
|
137
132
|
def df(device):
|
138
133
|
try:
|
139
|
-
out = sh("df -k
|
134
|
+
out = sh(f"df -k {device}").strip()
|
140
135
|
except RuntimeError as err:
|
141
136
|
if "device busy" in str(err).lower():
|
142
137
|
raise pytest.skip("df returned EBUSY")
|
@@ -288,7 +283,7 @@ class TestProcess(PsutilTestCase):
|
|
288
283
|
assert ps_pathname == psutil_pathname
|
289
284
|
except AssertionError:
|
290
285
|
# certain platforms such as BSD are more accurate returning:
|
291
|
-
# "/usr/local/bin/
|
286
|
+
# "/usr/local/bin/python3.7"
|
292
287
|
# ...instead of:
|
293
288
|
# "/usr/local/bin/python"
|
294
289
|
# We do not want to consider this difference in accuracy
|
@@ -348,7 +343,7 @@ class TestSystemAPIs(PsutilTestCase):
|
|
348
343
|
# for some reason ifconfig -a does not report all interfaces
|
349
344
|
# returned by psutil
|
350
345
|
@pytest.mark.skipif(SUNOS, reason="unreliable on SUNOS")
|
351
|
-
@pytest.mark.skipif(not which(
|
346
|
+
@pytest.mark.skipif(not shutil.which("ifconfig"), reason="no ifconfig cmd")
|
352
347
|
@pytest.mark.skipif(not HAS_NET_IO_COUNTERS, reason="not supported")
|
353
348
|
def test_nic_names(self):
|
354
349
|
output = sh("ifconfig -a")
|
@@ -358,8 +353,8 @@ class TestSystemAPIs(PsutilTestCase):
|
|
358
353
|
break
|
359
354
|
else:
|
360
355
|
raise self.fail(
|
361
|
-
"couldn't find
|
362
|
-
|
356
|
+
f"couldn't find {nic} nic in 'ifconfig -a'"
|
357
|
+
f" output\n{output}"
|
363
358
|
)
|
364
359
|
|
365
360
|
# @pytest.mark.skipif(CI_TESTING and not psutil.users(),
|
@@ -408,9 +403,7 @@ class TestSystemAPIs(PsutilTestCase):
|
|
408
403
|
started = [x.capitalize() for x in started]
|
409
404
|
|
410
405
|
if not tstamp:
|
411
|
-
raise pytest.skip(
|
412
|
-
"cannot interpret tstamp in who output\n%s" % (out)
|
413
|
-
)
|
406
|
+
raise pytest.skip(f"cannot interpret tstamp in who output\n{out}")
|
414
407
|
|
415
408
|
with self.subTest(psutil=psutil.users(), who=out):
|
416
409
|
for idx, u in enumerate(psutil.users()):
|