summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-05-23 15:13:06 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2020-05-23 15:13:06 +0200
commit0c3fce7bdce2202367821358a6e81558692a3368 (patch)
tree396d06ea0148ad2fd75adc931da233928009d258
parentc158bb349cd79b0d16921395d13f8ecef46e9de6 (diff)
downloadpsutil-0c3fce7bdce2202367821358a6e81558692a3368.tar.gz
fix race condition
-rw-r--r--psutil/tests/__init__.py2
-rwxr-xr-xpsutil/tests/test_process.py9
2 files changed, 8 insertions, 3 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index d7e9835d..b778885b 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -1478,7 +1478,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_process.py b/psutil/tests/test_process.py
index 6e4009c4..4be10ee7 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,7 +33,6 @@ from psutil import POSIX
from psutil import SUNOS
from psutil import WINDOWS
from psutil._common import open_text
-from psutil._common import path_exists_strict
from psutil._compat import long
from psutil._compat import PY3
from psutil._compat import super
@@ -638,7 +638,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 path_exists_strict(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)