From 06a925d91c914b2ea3aa585a08418f569cb44931 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Mon, 21 Nov 2022 09:21:37 +0000 Subject: [PATCH] - Updated a couple of tests for macOS. --- .gitignore | 2 ++ tests/test_ICCProfile.py | 5 +++-- tests/test_config.py | 10 ++++++---- tests/test_real_display_size_mm.py | 9 ++++++++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 403a6eeb..c2aaa996 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store /DisplayCAL/__version__.py /build/ /dist/ @@ -20,3 +21,4 @@ __pycache__/ /DisplayCAL/lib64/python38/*.so /DisplayCAL/lib64/python39/*.so /DisplayCAL/lib64/python310/*.so +/DisplayCAL/lib64/RealDisplaySizeMM.cpython-310-darwin.so diff --git a/tests/test_ICCProfile.py b/tests/test_ICCProfile.py index ce3ee05b..4a6d64ca 100644 --- a/tests/test_ICCProfile.py +++ b/tests/test_ICCProfile.py @@ -2,6 +2,7 @@ """Tests for the DisplayCAL.ICCProfile module.""" import binascii import datetime +import sys from time import strftime from DisplayCAL import ICCProfile, colormath @@ -37,7 +38,7 @@ def test_iccprofile_from_rgb_space(): ["Color model", "RGB"], ["Profile connection space (PCS)", "XYZ"], ["Created", "2022-03-09 00:19:53"], - ["Platform", "0x2A6E6978 '*nix'"], + ["Platform", "Apple"] if sys.platform == "darwin" else ["Platform", "0x2A6E6978 '*nix'"], ["Is embedded", "No"], ["Can be used independently", "Yes"], ["Device", ""], @@ -178,7 +179,7 @@ def test_iccprofile_get_info(): ["Color model", "RGB"], ["Profile connection space (PCS)", "XYZ"], ["Created", "2022-02-14 02:44:22"], - ["Platform", "0x2A6E6978 '*nix'"], + ["Platform", "Apple"] if sys.platform == "darwin" else ["Platform", "0x2A6E6978 '*nix'"], ["Is embedded", "No"], ["Can be used independently", "Yes"], ["Device", ""], diff --git a/tests/test_config.py b/tests/test_config.py index 159a3cdf..e03ff4c4 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -23,10 +23,12 @@ def test_default_values_1(): assert config.pyext != "" # .py # $HOME/Documents/development/displaycal/DisplayCAL assert config.pydir != "" - assert config.xdg_config_dir_default == "/etc/xdg" - assert config.xdg_config_home == os.path.expanduser("~/.config") - assert config.xdg_data_home == os.path.expanduser("~/.local/share") - assert config.xdg_data_home_default == os.path.expanduser("~/.local/share") + + if sys.platform == "linux": + assert config.xdg_config_dir_default == "/etc/xdg" + assert config.xdg_config_home == os.path.expanduser("~/.config") + assert config.xdg_data_home == os.path.expanduser("~/.local/share") + assert config.xdg_data_home_default == os.path.expanduser("~/.local/share") # skip the rest of the test for now return diff --git a/tests/test_real_display_size_mm.py b/tests/test_real_display_size_mm.py index cbb898ef..3c79b67c 100644 --- a/tests/test_real_display_size_mm.py +++ b/tests/test_real_display_size_mm.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import annotations +import sys from unittest import mock import pytest @@ -9,7 +10,11 @@ from DisplayCAL import RealDisplaySizeMM, config from DisplayCAL.dev.mocks import check_call from tests.data.display_data import DisplayData -from tests.data.fake_dbus import FakeDBusObject + +try: + from tests.data.fake_dbus import FakeDBusObject +except ImportError: + pass def test_real_display_size_mm(): @@ -112,6 +117,8 @@ def test_get_x_icc_profile_atom_id(function) -> None: assert isinstance(result, int) +@pytest.mark.skipif('fake_dbus' not in sys.modules, + reason="requires the DBus library") def test_get_wayland_display(monkeypatch: MonkeyPatch) -> None: """Test if wayland display is returned.""" with mock.patch.object(RealDisplaySizeMM, "DBusObject", new=FakeDBusObject):