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 63e7bda commit 41967f3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/tests/test_general/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import random
from pathlib import Path
from random import shuffle
from unittest.mock import Mock, patch
from unittest.mock import MagicMock, Mock, patch

import pytest

Expand Down Expand Up @@ -43,10 +43,21 @@ def mock_disk_usage():
@pytest.fixture
def mock_statvfs():
"""Fixture to mock os.statvfs."""
mock_stats = Mock()
mock_stats.f_frsize = 1024 # Fragment size
mock_stats.f_bavail = 1000 # Free blocks
return mock_stats
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
)

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
return mocked_statvfs


def test_replace_extension():
Expand Down

0 comments on commit 41967f3

Please sign in to comment.