Skip to content

Commit

Permalink
Test that Settings.color modifications are propagated to C++
Browse files Browse the repository at this point in the history
This extends test_settings to convert to the internal (C++) settings and
back, ensuring that the settings are propagated correctly to C++.
  • Loading branch information
johningve committed Dec 9, 2024
1 parent 2230fbd commit 22ee714
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 22ee714

Please sign in to comment.