Add tests/test_utils_namespace.py
Run CI Tests / test (push) Successful in 1m40s

This commit is contained in:
2025-08-04 15:23:20 +02:00
parent 5ed98a56ed
commit a71f7968cb
+29
View File
@@ -0,0 +1,29 @@
from types import SimpleNamespace
from slic.utils.namespace import Namespace
def test_namespace_pretty_repr_mixed_and_nested():
laser = SimpleNamespace(power="5W", wavelength="1030nm", mode="CW")
detector = SimpleNamespace(model="X-500")
stage = SimpleNamespace()
experiment = SimpleNamespace(id=42, meta=SimpleNamespace(author="Dr. X", approved=True))
ns = Namespace()
ns.laser = laser
ns.detector = detector
ns.stage = stage
ns.experiment = experiment
output = repr(ns)
expected = """\
laser : namespace(power='5W', wavelength='1030nm', mode='CW')
detector : namespace(model='X-500')
stage : namespace()
experiment: namespace(id=42, meta=namespace(author='Dr. X', approved=True))
"""
if not output.endswith("\n"):
output += "\n"
assert output == expected