Files
slic/tests/test_utils_namespace.py
T
tligui_y 2036b001fb
Run CI Tests / test (push) Successful in 1m40s
Update tests/test_utils_namespace.py
2025-08-04 15:41:39 +02:00

30 lines
835 B
Python

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 = """\
detector: namespace(model='X-500')
experiment: namespace(id=42, meta=namespace(author='Dr. X', approved=True))
laser: namespace(power='5W', wavelength='1030nm', mode='CW')
stage: namespace()
"""
if not output.endswith("\n"):
output += "\n"
assert output == expected