Skip to content

Commit

Permalink
try to fix some flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 19, 2024
1 parent 560c524 commit 45934bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
AF_LINK = _psplatform.AF_LINK

__author__ = "Giampaolo Rodola'"
__version__ = "6.1.0"
__version__ = "6.1.1"
version_info = tuple([int(num) for num in __version__.split('.')])

_timer = getattr(time, 'monotonic', time.time)
Expand Down
32 changes: 15 additions & 17 deletions psutil/tests/test_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,24 +1195,22 @@ def test_zfs_fs(self):
if 'zfs' in data:
for part in psutil.disk_partitions():
if part.fstype == 'zfs':
break
else:
raise self.fail("couldn't find any ZFS partition")
else:
# No ZFS partitions on this system. Let's fake one.
fake_file = io.StringIO(u"nodev\tzfs\n")
return

# No ZFS partitions on this system. Let's fake one.
fake_file = io.StringIO(u"nodev\tzfs\n")
with mock.patch(
'psutil._common.open', return_value=fake_file, create=True
) as m1:
with mock.patch(
'psutil._common.open', return_value=fake_file, create=True
) as m1:
with mock.patch(
'psutil._pslinux.cext.disk_partitions',
return_value=[('/dev/sdb3', '/', 'zfs', 'rw')],
) as m2:
ret = psutil.disk_partitions()
assert m1.called
assert m2.called
assert ret
assert ret[0].fstype == 'zfs'
'psutil._pslinux.cext.disk_partitions',
return_value=[('/dev/sdb3', '/', 'zfs', 'rw')],
) as m2:
ret = psutil.disk_partitions()
assert m1.called
assert m2.called
assert ret
assert ret[0].fstype == 'zfs'

def test_emulate_realpath_fail(self):
# See: https://github.com/giampaolo/psutil/issues/1307
Expand Down
3 changes: 2 additions & 1 deletion psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,8 @@ def test_long_name(self):
@pytest.mark.skipif(SUNOS, reason="broken on SUNOS")
@pytest.mark.skipif(AIX, reason="broken on AIX")
@pytest.mark.skipif(PYPY, reason="broken on PYPY")
@pytest.mark.skipif(QEMU_USER, reason="broken on QEMU user")
@pytest.mark.skipif(SUNOS, reason="broken on SUNOS")
@pytest.mark.skipif(MACOS and not PY3, reason="broken MACOS + PY2")
def test_prog_w_funky_name(self):
# Test that name(), exe() and cmdline() correctly handle programs
# with funky chars such as spaces and ")", see:
Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

import psutil
from psutil import BSD
from psutil import MACOS
from psutil import POSIX
from psutil import WINDOWS
from psutil._compat import PY3
Expand Down Expand Up @@ -195,6 +196,7 @@ def expect_exact_path_match(self):

# ---

@pytest.mark.skipif(MACOS and not PY3, reason="broken MACOS + PY2")
def test_proc_exe(self):
cmd = [
self.funky_name,
Expand All @@ -220,6 +222,7 @@ def test_proc_name(self):
if self.expect_exact_path_match():
assert name == os.path.basename(self.funky_name)

@pytest.mark.skipif(MACOS and not PY3, reason="broken MACOS + PY2")
def test_proc_cmdline(self):
cmd = [
self.funky_name,
Expand Down

0 comments on commit 45934bb

Please sign in to comment.