Skip to content

Commit

Permalink
Fix test on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson committed Dec 15, 2023
1 parent 41967f3 commit 20f7ab4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/tests/test_general/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ def mock_statvfs():
"""Fixture to mock os.statvfs."""
f_frsize = 1024
f_bavail = 1000
if not hasattr(os, "statvfs"):
# Windows doesn't have statvfs, so we need to mock it
mocked_statvfs = MagicMock()
mocked_statvfs.return_value = MagicMock(
f_frsize=f_frsize, f_bavail=f_bavail
)

# Create a MagicMock with specified attributes
mocked_statvfs_result = MagicMock(f_frsize=f_frsize, f_bavail=f_bavail)

# For Windows, where os.statvfs doesn't exist
if not hasattr(os, "statvfs"):
# Create a MagicMock for os.statvfs
mocked_statvfs = MagicMock(return_value=mocked_statvfs_result)
else:
# Linux/macOS has statvfs so only the values need to be set
mocked_statvfs = Mock()
mocked_statvfs.f_frsize = f_frsize # Fragment size
mocked_statvfs.f_bavail = f_bavail # Free blocks
# For Unix-like systems, return a Mock object that mimics the result
mocked_statvfs = Mock(return_value=mocked_statvfs_result)

return mocked_statvfs


Expand Down

0 comments on commit 20f7ab4

Please sign in to comment.