def add_parameter_from_dict(instr: Instrument, name: str, options: Dict[str, Any]): # keep the original dictionray intact for snapshot options = copy(options) if 'source' in options: instr.add_parameter(name, DelegateParameter, source=resolve_parameter_identifier( instr, options['source'])) options.pop('source') else: instr.add_parameter(name, Parameter) setup_parameter_from_dict(instr, name, options)
def test_base_instrument_errors(self): b = Instrument('silent', server_name=None) with self.assertRaises(NotImplementedError): b.write('hello!') with self.assertRaises(NotImplementedError): b.ask('how are you?') with self.assertRaises(TypeError): b.add_function('skip', call_cmd='skip {}', args=['not a validator']) with self.assertRaises(NoCommandError): b.add_function('jump') with self.assertRaises(NoCommandError): b.add_parameter('height')