summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.flake82
-rw-r--r--.travis.yml2
-rw-r--r--psutil/_pswindows.py8
-rw-r--r--psutil/tests/__init__.py20
-rwxr-xr-xpsutil/tests/test_contracts.py9
-rwxr-xr-xpsutil/tests/test_misc.py2
-rwxr-xr-xpsutil/tests/test_osx.py60
-rwxr-xr-xpsutil/tests/test_process.py19
-rwxr-xr-xpsutil/tests/test_system.py7
-rwxr-xr-xpsutil/tests/test_unicode.py23
-rwxr-xr-xpsutil/tests/test_windows.py77
-rwxr-xr-xscripts/internal/winmake.py14
-rwxr-xr-xsetup.py11
13 files changed, 107 insertions, 147 deletions
diff --git a/.flake8 b/.flake8
index e125df09..15efab52 100644
--- a/.flake8
+++ b/.flake8
@@ -4,8 +4,6 @@
[flake8]
ignore =
- # ambiguous variable name 'l'
- E741,
# line break after binary operator
W504
per-file-ignores =
diff --git a/.travis.yml b/.travis.yml
index d49f2cf1..e51ecf03 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ matrix:
env: PYVER=py27
- language: generic
os: osx
- env: PYVER=py36
+ env: PYVER=py38
# Linux
- python: 2.7
- python: 3.5
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index c1707db7..98baef59 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -1066,11 +1066,11 @@ class Process(object):
@wrap_exceptions
def cpu_affinity_set(self, value):
- def to_bitmask(l):
- if not l:
- raise ValueError("invalid argument %r" % l)
+ def to_bitmask(ls):
+ if not ls:
+ raise ValueError("invalid argument %r" % ls)
out = 0
- for b in l:
+ for b in ls:
out |= 2 ** b
return out
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index d3d02d11..6a119bf5 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -54,10 +54,10 @@ from psutil._compat import u
from psutil._compat import unicode
from psutil._compat import which
-if sys.version_info < (2, 7):
- import unittest2 as unittest # requires "pip install unittest2"
-else:
+if PY3:
import unittest
+else:
+ import unittest2 as unittest # requires "pip install unittest2"
try:
from unittest import mock # py3
@@ -77,7 +77,7 @@ __all__ = [
'APPVEYOR', 'DEVNULL', 'GLOBAL_TIMEOUT', 'TOLERANCE_SYS_MEM', 'NO_RETRIES',
'PYPY', 'PYTHON_EXE', 'ROOT_DIR', 'SCRIPTS_DIR', 'TESTFN_PREFIX',
'UNICODE_SUFFIX', 'INVALID_UNICODE_SUFFIX', 'TOX', 'TRAVIS', 'CIRRUS',
- 'CI_TESTING', 'VALID_PROC_STATUSES', 'TOLERANCE_DISK_USAGE',
+ 'CI_TESTING', 'VALID_PROC_STATUSES', 'TOLERANCE_DISK_USAGE', 'IS_64BIT',
"HAS_CPU_AFFINITY", "HAS_CPU_FREQ", "HAS_ENVIRON", "HAS_PROC_IO_COUNTERS",
"HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT",
"HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS",
@@ -125,13 +125,16 @@ APPVEYOR = 'APPVEYOR' in os.environ
CIRRUS = 'CIRRUS' in os.environ
GITHUB_WHEELS = 'CIBUILDWHEEL' in os.environ
CI_TESTING = TRAVIS or APPVEYOR or CIRRUS or GITHUB_WHEELS
+# are we a 64 bit process?
+IS_64BIT = sys.maxsize > 2 ** 32
+
# --- configurable defaults
# how many times retry_on_failure() decorator will retry
NO_RETRIES = 10
# bytes tolerance for system-wide related tests
-TOLERANCE_SYS_MEM = 500 * 1024 # 500KB
+TOLERANCE_SYS_MEM = 5 * 1024 * 1024 # 5MB
TOLERANCE_DISK_USAGE = 10 * 1024 * 1024 # 10MB
# the timeout used in functions which have to wait
GLOBAL_TIMEOUT = 5
@@ -203,7 +206,10 @@ def _get_py_exe():
return exe
if GITHUB_WHEELS:
- return which('python')
+ if PYPY:
+ return which("pypy3") if PY3 else which("pypy")
+ else:
+ return which('python')
elif MACOS:
exe = \
attempt(sys.executable) or \
@@ -1475,7 +1481,7 @@ def check_net_address(addr, family):
IPv6 and MAC addresses.
"""
import ipaddress # python >= 3.3 / requires "pip install ipaddress"
- if enum and PY3:
+ if enum and PY3 and not PYPY:
assert isinstance(family, enum.IntEnum), family
if family == socket.AF_INET:
octs = [int(x) for x in addr.split('.')]
diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py
index 57d11b43..35ab61e0 100755
--- a/psutil/tests/test_contracts.py
+++ b/psutil/tests/test_contracts.py
@@ -41,6 +41,7 @@ from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import is_namedtuple
from psutil.tests import process_namespace
from psutil.tests import PsutilTestCase
+from psutil.tests import PYPY
from psutil.tests import serialrun
from psutil.tests import SKIP_SYSCONS
from psutil.tests import unittest
@@ -247,7 +248,7 @@ class TestSystemAPITypes(PsutilTestCase):
for ifname, addrs in psutil.net_if_addrs().items():
self.assertIsInstance(ifname, str)
for addr in addrs:
- if enum is not None:
+ if enum is not None and not PYPY:
self.assertIsInstance(addr.family, enum.IntEnum)
else:
self.assertIsInstance(addr.family, int)
@@ -381,13 +382,15 @@ class TestFetchAllProcesses(PsutilTestCase):
self.pool.terminate()
self.pool.join()
- def test_all(self):
+ def iter_proc_info(self):
# Fixes "can't pickle <function proc_info>: it's not the
# same object as test_contracts.proc_info".
from psutil.tests.test_contracts import proc_info
+ return self.pool.imap_unordered(proc_info, psutil.pids())
+ def test_all(self):
failures = []
- for info in self.pool.imap_unordered(proc_info, psutil.pids()):
+ for info in self.iter_proc_info():
for name, value in info.items():
meth = getattr(self, name)
try:
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index becd930a..10e45d23 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -323,7 +323,7 @@ class TestMisc(PsutilTestCase):
side_effect=OSError(errno.EACCES, "foo")):
self.assertRaises(OSError, isfile_strict, this_file)
with mock.patch('psutil._common.os.stat',
- side_effect=OSError(errno.EINVAL, "foo")):
+ side_effect=OSError(errno.ENOENT, "foo")):
assert not isfile_strict(this_file)
with mock.patch('psutil._common.stat.S_ISREG', return_value=False):
assert not isfile_strict(this_file)
diff --git a/psutil/tests/test_osx.py b/psutil/tests/test_osx.py
index 14f6d149..097bff10 100755
--- a/psutil/tests/test_osx.py
+++ b/psutil/tests/test_osx.py
@@ -17,7 +17,6 @@ from psutil.tests import PsutilTestCase
from psutil.tests import retry_on_failure
from psutil.tests import sh
from psutil.tests import spawn_testproc
-from psutil.tests import spawn_zombie
from psutil.tests import terminate
from psutil.tests import TOLERANCE_DISK_USAGE
from psutil.tests import TOLERANCE_SYS_MEM
@@ -102,65 +101,6 @@ class TestProcess(PsutilTestCase):
time.strftime("%Y", time.localtime(start_psutil)))
-# TODO: probably needs removal (duplicate)
-@unittest.skipIf(not MACOS, "MACOS only")
-class TestZombieProcessAPIs(PsutilTestCase):
-
- @classmethod
- def setUpClass(cls):
- cls.parent, cls.zombie = spawn_zombie()
-
- @classmethod
- def tearDownClass(cls):
- terminate(cls.parent)
- terminate(cls.zombie)
-
- def test_pidtask_info(self):
- self.assertEqual(self.zombie.status(), psutil.STATUS_ZOMBIE)
- self.zombie.ppid()
- self.zombie.uids()
- self.zombie.gids()
- self.zombie.terminal()
- self.zombie.create_time()
-
- def test_exe(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.exe)
-
- def test_cmdline(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.cmdline)
-
- def test_environ(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.environ)
-
- def test_cwd(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.cwd)
-
- def test_memory_full_info(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.memory_full_info)
-
- def test_cpu_times(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.cpu_times)
-
- def test_num_ctx_switches(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.num_ctx_switches)
-
- def test_num_threads(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.num_threads)
-
- def test_open_files(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.open_files)
-
- def test_connections(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.connections)
-
- def test_num_fds(self):
- self.assertRaises(psutil.ZombieProcess, self.zombie.num_fds)
-
- def test_threads(self):
- self.assertRaises((psutil.ZombieProcess, psutil.AccessDenied),
- self.zombie.threads)
-
-
@unittest.skipIf(not MACOS, "MACOS only")
class TestSystemAPIs(PsutilTestCase):
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index 4a21cae5..a0b21c6e 100755
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -13,6 +13,7 @@ import itertools
import os
import signal
import socket
+import stat
import subprocess
import sys
import textwrap
@@ -32,6 +33,7 @@ from psutil import POSIX
from psutil import SUNOS
from psutil import WINDOWS
from psutil._common import open_text
+from psutil._compat import FileNotFoundError
from psutil._compat import long
from psutil._compat import PY3
from psutil._compat import super
@@ -637,7 +639,12 @@ class TestProcess(PsutilTestCase):
# 64 bit dlls: they are visible via explorer but cannot
# be accessed via os.stat() (wtf?).
if '64' not in os.path.basename(nt.path):
- assert os.path.exists(nt.path), nt.path
+ try:
+ st = os.stat(nt.path)
+ except FileNotFoundError:
+ pass
+ else:
+ assert stat.S_ISREG(st.st_mode), nt.path
for nt in ext_maps:
for fname in nt._fields:
value = getattr(nt, fname)
@@ -923,8 +930,8 @@ class TestProcess(PsutilTestCase):
if len(initial) > 12:
initial = initial[:12] # ...otherwise it will take forever
combos = []
- for l in range(0, len(initial) + 1):
- for subset in itertools.combinations(initial, l):
+ for i in range(0, len(initial) + 1):
+ for subset in itertools.combinations(initial, i):
if subset:
combos.append(list(subset))
@@ -1271,7 +1278,7 @@ class TestProcess(PsutilTestCase):
assert_raises_nsp(fun, name)
# NtQuerySystemInformation succeeds even if process is gone.
- if WINDOWS:
+ if WINDOWS and not GITHUB_WHEELS:
normcase = os.path.normcase
self.assertEqual(normcase(p.exe()), normcase(PYTHON_EXE))
@@ -1509,9 +1516,9 @@ class TestPopen(PsutilTestCase):
self.assertRaises(AttributeError, getattr, proc, 'foo')
proc.terminate()
if POSIX:
- self.assertEqual(proc.wait(), -signal.SIGTERM)
+ self.assertEqual(proc.wait(5), -signal.SIGTERM)
else:
- self.assertEqual(proc.wait(), signal.SIGTERM)
+ self.assertEqual(proc.wait(5), signal.SIGTERM)
def test_ctx_manager(self):
with psutil.Popen([PYTHON_EXE, "-V"],
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 004f4882..e368ea76 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -43,6 +43,7 @@ from psutil.tests import HAS_NET_IO_COUNTERS
from psutil.tests import HAS_SENSORS_BATTERY
from psutil.tests import HAS_SENSORS_FANS
from psutil.tests import HAS_SENSORS_TEMPERATURES
+from psutil.tests import IS_64BIT
from psutil.tests import mock
from psutil.tests import PsutilTestCase
from psutil.tests import PYPY
@@ -544,8 +545,7 @@ class TestCpuAPIs(PsutilTestCase):
@unittest.skipIf(not HAS_GETLOADAVG, "not supported")
def test_getloadavg(self):
loadavg = psutil.getloadavg()
- assert len(loadavg) == 3
-
+ self.assertEqual(len(loadavg), 3)
for load in loadavg:
self.assertIsInstance(load, float)
self.assertGreaterEqual(load, 0.0)
@@ -553,6 +553,7 @@ class TestCpuAPIs(PsutilTestCase):
class TestDiskAPIs(PsutilTestCase):
+ @unittest.skipIf(PYPY and not IS_64BIT, "unreliable on PYPY32 + 32BIT")
def test_disk_usage(self):
usage = psutil.disk_usage(os.getcwd())
self.assertEqual(usage._fields, ('total', 'used', 'free', 'percent'))
@@ -748,7 +749,7 @@ class TestNetAPIs(PsutilTestCase):
self.assertIsInstance(addr.netmask, (str, type(None)))
self.assertIsInstance(addr.broadcast, (str, type(None)))
self.assertIn(addr.family, families)
- if sys.version_info >= (3, 4):
+ if sys.version_info >= (3, 4) and not PYPY:
self.assertIsInstance(addr.family, enum.IntEnum)
if nic_stats[nic].isup:
# Do not test binding to addresses of interfaces
diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py
index af421d4e..fba56239 100755
--- a/psutil/tests/test_unicode.py
+++ b/psutil/tests/test_unicode.py
@@ -74,12 +74,12 @@ etc.) and make sure that:
"""
import os
+import shutil
import traceback
import warnings
from contextlib import closing
from psutil import BSD
-from psutil import MACOS
from psutil import OPENBSD
from psutil import POSIX
from psutil import WINDOWS
@@ -107,7 +107,6 @@ from psutil.tests import skip_on_access_denied
from psutil.tests import spawn_testproc
from psutil.tests import terminate
from psutil.tests import TESTFN_PREFIX
-from psutil.tests import TRAVIS
from psutil.tests import UNICODE_SUFFIX
from psutil.tests import unittest
import psutil
@@ -132,7 +131,7 @@ if APPVEYOR:
traceback.print_exc()
-def subprocess_supports_unicode(suffix):
+def try_unicode(suffix):
"""Return True if both the fs and the subprocess module can
deal with a unicode file name.
"""
@@ -144,6 +143,8 @@ def subprocess_supports_unicode(suffix):
safe_rmpath(testfn)
create_exe(testfn)
sproc = spawn_testproc(cmd=[testfn])
+ shutil.copyfile(testfn, testfn + '-2')
+ safe_rmpath(testfn + '-2')
except (UnicodeEncodeError, IOError):
return False
else:
@@ -160,6 +161,8 @@ def subprocess_supports_unicode(suffix):
@serialrun
+@unittest.skipIf(ASCII_FS, "ASCII fs")
+@unittest.skipIf(PYPY and not PY3, "too much trouble on PYPY2")
class _BaseFSAPIsTests(object):
funky_suffix = None
@@ -297,11 +300,10 @@ class _BaseFSAPIsTests(object):
# https://travis-ci.org/giampaolo/psutil/jobs/440073249
-@unittest.skipIf(PYPY and TRAVIS, "unreliable on PYPY + TRAVIS")
-@unittest.skipIf(MACOS and TRAVIS, "unreliable on TRAVIS") # TODO
-@unittest.skipIf(ASCII_FS, "ASCII fs")
-@unittest.skipIf(not subprocess_supports_unicode(UNICODE_SUFFIX),
- "subprocess can't deal with unicode")
+# @unittest.skipIf(PYPY and TRAVIS, "unreliable on PYPY + TRAVIS")
+# @unittest.skipIf(MACOS and TRAVIS, "unreliable on TRAVIS") # TODO
+@unittest.skipIf(not try_unicode(UNICODE_SUFFIX),
+ "can't deal with unicode str")
class TestFSAPIs(_BaseFSAPIsTests, PsutilTestCase):
"""Test FS APIs with a funky, valid, UTF8 path name."""
funky_suffix = UNICODE_SUFFIX
@@ -316,9 +318,8 @@ class TestFSAPIs(_BaseFSAPIsTests, PsutilTestCase):
@unittest.skipIf(CI_TESTING, "unreliable on CI")
-@unittest.skipIf(PYPY, "unreliable on PYPY")
-@unittest.skipIf(not subprocess_supports_unicode(INVALID_UNICODE_SUFFIX),
- "subprocess can't deal with invalid unicode")
+@unittest.skipIf(not try_unicode(INVALID_UNICODE_SUFFIX),
+ "can't deal with invalid unicode str")
class TestFSAPIsWithInvalidPath(_BaseFSAPIsTests, PsutilTestCase):
"""Test FS APIs with a funky, invalid path name."""
funky_suffix = INVALID_UNICODE_SUFFIX
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index 7647395a..945bb2ed 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -24,22 +24,25 @@ from psutil import WINDOWS
from psutil._compat import FileNotFoundError
from psutil._compat import super
from psutil.tests import APPVEYOR
-from psutil.tests import spawn_testproc
+from psutil.tests import GITHUB_WHEELS
from psutil.tests import HAS_BATTERY
+from psutil.tests import IS_64BIT
from psutil.tests import mock
from psutil.tests import PsutilTestCase
from psutil.tests import PY3
from psutil.tests import PYPY
from psutil.tests import retry_on_failure
from psutil.tests import sh
+from psutil.tests import spawn_testproc
from psutil.tests import terminate
+from psutil.tests import TOLERANCE_DISK_USAGE
from psutil.tests import unittest
if WINDOWS and not PYPY:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
- import win32api # requires "pip install pypiwin32"
+ import win32api # requires "pip install pywin32"
import win32con
import win32process
import wmi # requires "pip install wmi" / "make setup-dev-env"
@@ -47,9 +50,6 @@ if WINDOWS and not PYPY:
cext = psutil._psplatform.cext
-# are we a 64 bit process
-IS_64_BIT = sys.maxsize > 2**32
-
def wrap_exceptions(fun):
def wrapper(self, *args, **kwargs):
@@ -65,8 +65,12 @@ def wrap_exceptions(fun):
return wrapper
-@unittest.skipIf(PYPY, "pywin32 not available on PYPY") # skip whole module
-class TestCase(PsutilTestCase):
+@unittest.skipIf(not WINDOWS, "WINDOWS only")
+@unittest.skipIf(PYPY, "pywin32 not available on PYPY")
+# https://github.com/giampaolo/psutil/pull/1762#issuecomment-632892692
+@unittest.skipIf(GITHUB_WHEELS and (not PY3 or not IS_64BIT),
+ "pywin32 broken on GITHUB + PY2")
+class WindowsTestCase(PsutilTestCase):
pass
@@ -75,8 +79,7 @@ class TestCase(PsutilTestCase):
# ===================================================================
-@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestCpuAPIs(TestCase):
+class TestCpuAPIs(WindowsTestCase):
@unittest.skipIf('NUMBER_OF_PROCESSORS' not in os.environ,
'NUMBER_OF_PROCESSORS env var is not available')
@@ -114,8 +117,7 @@ class TestCpuAPIs(TestCase):
self.assertEqual(proc.MaxClockSpeed, psutil.cpu_freq().max)
-@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestSystemAPIs(TestCase):
+class TestSystemAPIs(WindowsTestCase):
def test_nic_names(self):
out = sh('ipconfig /all')
@@ -184,6 +186,7 @@ class TestSystemAPIs(TestCase):
else:
self.fail("can't find partition %s" % repr(ps_part))
+ @retry_on_failure()
def test_disk_usage(self):
for disk in psutil.disk_partitions():
if 'cdrom' in disk.opts:
@@ -191,9 +194,9 @@ class TestSystemAPIs(TestCase):
sys_value = win32api.GetDiskFreeSpaceEx(disk.mountpoint)
psutil_value = psutil.disk_usage(disk.mountpoint)
self.assertAlmostEqual(sys_value[0], psutil_value.free,
- delta=1024 * 1024)
+ delta=TOLERANCE_DISK_USAGE)
self.assertAlmostEqual(sys_value[1], psutil_value.total,
- delta=1024 * 1024)
+ delta=TOLERANCE_DISK_USAGE)
self.assertEqual(psutil_value.used,
psutil_value.total - psutil_value.free)
@@ -202,7 +205,7 @@ class TestSystemAPIs(TestCase):
x + '\\' for x in win32api.GetLogicalDriveStrings().split("\\\x00")
if x and not x.startswith('A:')]
psutil_value = [x.mountpoint for x in psutil.disk_partitions(all=True)
- if not x.startswith('A:')]
+ if not x.mountpoint.startswith('A:')]
self.assertEqual(sys_value, psutil_value)
def test_net_if_stats(self):
@@ -241,8 +244,7 @@ class TestSystemAPIs(TestCase):
# ===================================================================
-@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestSensorsBattery(TestCase):
+class TestSensorsBattery(WindowsTestCase):
def test_has_battery(self):
if win32api.GetPwrCapabilities()['SystemBatteriesPresent']:
@@ -302,8 +304,7 @@ class TestSensorsBattery(TestCase):
# ===================================================================
-@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestProcess(PsutilTestCase):
+class TestProcess(WindowsTestCase):
@classmethod
def setUpClass(cls):
@@ -494,8 +495,7 @@ class TestProcess(PsutilTestCase):
self.assertRaises(psutil.NoSuchProcess, proc.exe)
-@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestProcessWMI(TestCase):
+class TestProcessWMI(WindowsTestCase):
"""Compare Process API results with WMI."""
@classmethod
@@ -511,6 +511,7 @@ class TestProcessWMI(TestCase):
p = psutil.Process(self.pid)
self.assertEqual(p.name(), w.Caption)
+ @unittest.skipIf(GITHUB_WHEELS, "unreliable path on GITHUB_WHEELS")
def test_exe(self):
w = wmi.WMI().Win32_Process(ProcessId=self.pid)[0]
p = psutil.Process(self.pid)
@@ -531,15 +532,15 @@ class TestProcessWMI(TestCase):
username = "%s\\%s" % (domain, username)
self.assertEqual(p.username(), username)
+ @retry_on_failure()
def test_memory_rss(self):
- time.sleep(0.1)
w = wmi.WMI().Win32_Process(ProcessId=self.pid)[0]
p = psutil.Process(self.pid)
rss = p.memory_info().rss
self.assertEqual(rss, int(w.WorkingSetSize))
+ @retry_on_failure()
def test_memory_vms(self):
- time.sleep(0.1)
w = wmi.WMI().Win32_Process(ProcessId=self.pid)[0]
p = psutil.Process(self.pid)
vms = p.memory_info().vms
@@ -560,8 +561,11 @@ class TestProcessWMI(TestCase):
self.assertEqual(wmic_create, psutil_create)
+# ---
+
+
@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestDualProcessImplementation(TestCase):
+class TestDualProcessImplementation(PsutilTestCase):
"""
Certain APIs on Windows have 2 internal implementations, one
based on documented Windows APIs, another one based
@@ -664,28 +668,25 @@ class RemoteProcessTestCase(PsutilTestCase):
stderr=subprocess.STDOUT)
output, _ = proc.communicate()
proc.wait()
- if output == str(not IS_64_BIT):
+ if output == str(not IS_64BIT):
return filename
- @classmethod
- def setUpClass(cls):
- other_python = cls.find_other_interpreter()
+ test_args = ["-c", "import sys; sys.stdin.read()"]
+
+ def setUp(self):
+ super().setUp()
+ other_python = self.find_other_interpreter()
if other_python is None:
raise unittest.SkipTest(
"could not find interpreter with opposite bitness")
-
- if IS_64_BIT:
- cls.python64 = sys.executable
- cls.python32 = other_python
+ if IS_64BIT:
+ self.python64 = sys.executable
+ self.python32 = other_python
else:
- cls.python64 = other_python
- cls.python32 = sys.executable
-
- test_args = ["-c", "import sys; sys.stdin.read()"]
+ self.python64 = other_python
+ self.python32 = sys.executable
- def setUp(self):
- super().setUp()
env = os.environ.copy()
env["THINK_OF_A_NUMBER"] = str(os.getpid())
self.proc32 = self.spawn_testproc(
@@ -740,7 +741,7 @@ class RemoteProcessTestCase(PsutilTestCase):
@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestServices(TestCase):
+class TestServices(PsutilTestCase):
def test_win_service_iter(self):
valid_statuses = set([
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py
index 8fc3a984..3d9d0a8d 100755
--- a/scripts/internal/winmake.py
+++ b/scripts/internal/winmake.py
@@ -47,21 +47,19 @@ DEPS = [
"pyreadline",
"setuptools",
"wheel",
- "wmi",
"requests"
]
-if sys.version_info[:2] <= (2, 6):
+if sys.version_info[:2] <= (2, 7):
DEPS.append('unittest2')
if sys.version_info[:2] <= (2, 7):
DEPS.append('mock')
if sys.version_info[:2] <= (3, 2):
DEPS.append('ipaddress')
-if PYPY:
- pass
-elif sys.version_info[:2] <= (3, 4):
- DEPS.append("pypiwin32==219")
-else:
- DEPS.append("pypiwin32")
+if sys.version_info[:2] <= (3, 4):
+ DEPS.append('enum34')
+if not PYPY:
+ DEPS.append("pywin32")
+ DEPS.append("wmi")
_cmds = {}
if PY3:
diff --git a/setup.py b/setup.py
index ac7b8b53..3c442302 100755
--- a/setup.py
+++ b/setup.py
@@ -47,6 +47,7 @@ from _compat import PY3 # NOQA
from _compat import which # NOQA
+PYPY = '__pypy__' in sys.builtin_module_names
macros = []
if POSIX:
macros.append(("PSUTIL_POSIX", 1))
@@ -68,11 +69,15 @@ if POSIX:
extras_require = {"test": [
+ "enum34; python_version <= '3.4'",
"ipaddress; python_version < '3.0'",
"mock; python_version < '3.0'",
- "pypiwin32; sys.platform == 'win32'",
- "wmi; sys.platform == 'win32'",
- "enum34; python_version <= '3.4'"]}
+ "unittest2; python_version < '3.0'",
+]}
+if not PYPY:
+ extras_require['test'].extend([
+ "pywin32; sys.platform == 'win32'",
+ "wmi; sys.platform == 'win32'"])
def get_version():