def test_api(self): """Create a TestApi for access to this TestState. The returned TestApi should be passed as the first argument to test phases. Note that the return value is None if there is no self.running_phase_state set. As such, this attribute should only be accessed within a RunningPhaseContext(). Returns: openhtf.TestApi """ if not self.running_phase_state: raise ValueError('test_api only available when phase is running.') if not self._running_test_api: ps = self.running_phase_state self._running_test_api = openhtf.TestApi( self.logger, self.user_defined_state, self.test_record, measurements.Collection(ps.measurements), ps.attachments, ps.attach, ps.attach_from_file, self.get_measurement, self.get_attachment, self.notify_update, ) return self._running_test_api
def test_api(self): """Create a TestApi for access to this TestState. The returned TestApi should be passed as the first argument to test phases. Note that the return value is none if there is no self.running_phase_state set. As such, this attribute should only be accessed within a RunningPhaseContext(). """ running_phase_state = self.running_phase_state return (running_phase_state and openhtf.TestApi( self.logger, self.user_defined_state, self.test_record, measurements.Collection(running_phase_state.measurements), running_phase_state.attachments, running_phase_state.attach, running_phase_state.attach_from_file, self.notify_update))
def test_api(self) -> 'test_descriptor.TestApi': """Create a TestApi for access to this TestState. The returned TestApi should be passed as the first argument to test phases. This attribute must only be accessed within a running_phase_context(). Raises: ValueError: when not in a running_phase_context. Returns: openhtf.TestApi """ if not self.running_phase_state: raise ValueError('test_api only available when phase is running.') if not self._running_test_api: self._running_test_api = openhtf.TestApi( measurements=measurements.Collection( self.running_phase_state.measurements), running_phase_state=self.running_phase_state, running_test_state=self, ) return self._running_test_api