From 47b54e3f9928efa2fca6498de65aa9160ce22a86 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 27 Jan 2026 23:43:03 -0500 Subject: [PATCH] Update Windows Mocking for Tests --- .github/workflows/push-checks.yml | 3 ++- tests/test_dashboard.py | 2 ++ tests/test_l10n.py | 2 ++ tests/test_shiputils.py | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-checks.yml b/.github/workflows/push-checks.yml index 50315c1d..91241c7a 100644 --- a/.github/workflows/push-checks.yml +++ b/.github/workflows/push-checks.yml @@ -32,6 +32,7 @@ jobs: python-version-file: '.python-version' - name: Install dependencies run: | + sudo apt-get install -y xvfb python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi @@ -79,4 +80,4 @@ jobs: #################################################################### - name: PyTest tests run: | - pytest + xvfb-run pytest diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 548c7967..49681c28 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -4,6 +4,7 @@ import pytest import json +import sys from unittest.mock import MagicMock, patch import dashboard @@ -30,6 +31,7 @@ class TestDashboard: ) return d + @pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific logic") def test_start_logic_windows(self, mock_root, temp_journal_dir): """Verify observer setup on Windows platform.""" with patch("sys.platform", "win32"), patch( diff --git a/tests/test_l10n.py b/tests/test_l10n.py index 400f258a..8c40ec6f 100644 --- a/tests/test_l10n.py +++ b/tests/test_l10n.py @@ -4,6 +4,7 @@ import pytest from unittest.mock import patch +import sys import l10n @@ -101,6 +102,7 @@ class TestLocaleUtils: assert l10n.Locale.number_from_string("100") == 100 assert l10n.Locale.number_from_string("not_a_number") is None + @pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific logic") def test_preferred_languages_mapping(self): """Verify the zh-CN to zh-Hans hack works.""" with patch("sys.platform", "win32"): diff --git a/tests/test_shiputils.py b/tests/test_shiputils.py index 209e051d..85f0ee0e 100644 --- a/tests/test_shiputils.py +++ b/tests/test_shiputils.py @@ -2,6 +2,8 @@ # mypy: ignore-errors """Test util_ships.""" +import pytest +import sys from unittest.mock import patch import util_ships @@ -22,6 +24,7 @@ class TestShipUtils: assert util_ships.ship_file_name("MyShip.txt", "Sidewinder") == "MyShip" assert util_ships.ship_file_name("Config.json", "CobraMkIII") == "Config" + @pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific logic") @patch("sys.platform", "win32") @patch("os.path.isreserved") def test_ship_file_name_reserved_windows(self, mock_isreserved):