From d66c4725706a227681fe961da54cfffefd0f0dac Mon Sep 17 00:00:00 2001 From: Zachary Lentz Date: Fri, 30 Mar 2018 16:10:19 -0700 Subject: [PATCH] TST: Add test for recursive adds of subcomponents --- hutch_python/tests/test_namespace.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hutch_python/tests/test_namespace.py b/hutch_python/tests/test_namespace.py index 19e60121..4b501ae8 100644 --- a/hutch_python/tests/test_namespace.py +++ b/hutch_python/tests/test_namespace.py @@ -1,6 +1,9 @@ import logging from types import SimpleNamespace +from ophyd.device import Device, Component +from ophyd.signal import Signal + from hutch_python.namespace import class_namespace, metadata_namespace @@ -22,6 +25,22 @@ def test_class_namespace(): assert len(err_space) == 0 +class NormalDevice(Device): + apples = Component(Device) + oranges = Component(Signal) + + +def test_class_namespace_subdevices(): + logger.debug('test_class_namespace_subdevices') + scope = SimpleNamespace(tree=NormalDevice(name='tree')) + device_space = class_namespace(Device, scope) + assert isinstance(device_space.tree_apples, Device) + assert isinstance(device_space.tree, NormalDevice) + assert not hasattr(device_space, 'apples') + assert not hasattr(device_space, 'oranges') + assert not hasattr(device_space, 'tree_oranges') + + def test_metadata_namespace(): logger.debug('test_metadata_namespace') obj1 = SimpleNamespace()