Files
slic/tests/test_utils_namespace.py
T
tligui_y da29694838
Run CI Tests / test (push) Successful in 1m42s
Update tests/test_utils_namespace.py
2025-08-05 10:57:43 +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(approved=True, author='Dr. X'))
laser: namespace(mode='CW', power='5W', wavelength='1030nm')
stage: namespace()
"""
if not output.endswith("\n"):
output += "\n"
assert output == expected