Ejemplo n.º 1
0
def make_decl(members):
    d = Driver(driver='tests.instruments.false_driver:FalseDriver',
               model='E8257D')
    for m, v in members:
        parent = Drivers(**{m: v})
        d.set_parent(parent)
        d = parent

    return d
Ejemplo n.º 2
0
def test_handling_missing_non_required_members2(collector):
    """Test registering a driver without values for the non-required members.

    Case in which the declarator has no parent.

    """
    tb = {}
    m = dict(DEFAULT_MEMBERS)
    del m['serie']
    del m['kind']
    del m['settings']
    decl = Driver(driver='tests.instruments.false_driver:FalseDriver',
                  model='E8257D',
                  parent=None,
                  **m)
    decl.register(collector, tb)
    assert not tb
    assert len(collector.contributions) == 1
    d = collector.contributions['tests.lantz.FalseDriver']
    for m, v in (('kind', 'Other'), ('serie', ''), ('settings', {})):
        try:
            assert getattr(d, m) == v
        except AttributeError:
            assert d.infos[m] == v