Skip to content

Commit

Permalink
TST: Add test for recursive adds of subcomponents
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLLentz committed Mar 30, 2018
1 parent b9644ce commit d66c472
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hutch_python/tests/test_namespace.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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()
Expand Down

0 comments on commit d66c472

Please sign in to comment.