From 22ee71442a56c32044ab8ed1816bd24f007daffc Mon Sep 17 00:00:00 2001 From: John Ingve Olsen Date: Mon, 9 Dec 2024 14:58:05 +0100 Subject: [PATCH] Test that Settings.color modifications are propagated to C++ This extends test_settings to convert to the internal (C++) settings and back, ensuring that the settings are propagated correctly to C++. --- test/test_settings.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_settings.py b/test/test_settings.py index 5908c3e1..9a38037d 100644 --- a/test/test_settings.py +++ b/test/test_settings.py @@ -131,30 +131,49 @@ def test_default_settings(application): def test_set_color_settings(): + # pylint: disable=protected-access + from zivid import Settings, Settings2D + from zivid.settings import _to_settings, _to_internal_settings settings = Settings() assert settings.color is None + to_cpp_and_back = _to_settings(_to_internal_settings(settings)) + assert to_cpp_and_back.color is None + assert to_cpp_and_back == settings + settings.color = Settings2D() assert settings.color is not None assert isinstance(settings.color, Settings2D) assert settings.color == Settings2D() + to_cpp_and_back = _to_settings(_to_internal_settings(settings)) + assert to_cpp_and_back.color is not None + assert to_cpp_and_back == settings settings = Settings(color=Settings2D()) assert settings.color is not None assert isinstance(settings.color, Settings2D) assert settings.color == Settings2D() + to_cpp_and_back = _to_settings(_to_internal_settings(settings)) + assert to_cpp_and_back.color is not None + assert to_cpp_and_back == settings settings = Settings(color=Settings2D(acquisitions=(Settings2D.Acquisition(),))) assert settings.color is not None assert isinstance(settings.color, Settings2D) assert len(settings.color.acquisitions) == 1 + to_cpp_and_back = _to_settings(_to_internal_settings(settings)) + assert to_cpp_and_back.color is not None + assert to_cpp_and_back == settings settings = Settings() settings.color = Settings2D() settings.color.acquisitions.append(Settings2D.Acquisition()) assert len(settings.color.acquisitions) == 1 + to_cpp_and_back = _to_settings(_to_internal_settings(settings)) + assert len(to_cpp_and_back.color.acquisitions) == 1 + assert to_cpp_and_back == settings def test_set_acquisition_list():