From 20f7ab43ba59355439725c5c6944b84651631470 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 15 Dec 2023 12:30:51 +0000 Subject: [PATCH] Fix test on Windows --- tests/tests/test_general/test_system.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/tests/test_general/test_system.py b/tests/tests/test_general/test_system.py index 2aa878f..544ce4c 100644 --- a/tests/tests/test_general/test_system.py +++ b/tests/tests/test_general/test_system.py @@ -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