How to use nimodinst - 10 common examples

To help you get started, we’ve selected a few nimodinst examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ni / nimi-python / src / nimodinst / system_tests / test_system_nimodinst.py View on Github external
def test_socket_number_attribute():
    with nimodinst.Session('') as session:
        assert len(session) > 0, 'Must have hardware for ModInst tests to be valid.'
        assert isinstance(session.devices[0].socket_number, int)
github ni / nimi-python / generated / nimodinst / unit_tests / test_modinst.py View on Github external
def test_cannot_add_properties_to_session_get(self):
        with nimodinst.Session('') as session:
            try:
                session.non_existent_property
                assert False
            except AttributeError as e:
                assert str(e) == "'Session' object has no attribute 'non_existent_property'"
github ni / nimi-python / generated / nimodinst / unit_tests / test_modinst.py View on Github external
def test_int_attribute_warning(self):
        warning_code = 1234
        error_string = 'Error'
        self.patched_library.niModInst_GetInstalledDeviceAttributeViInt32.side_effect = self.side_effects_helper.niModInst_GetInstalledDeviceAttributeViInt32
        self.side_effects_helper['GetInstalledDeviceAttributeViInt32']['attributeValue'] = -1
        self.side_effects_helper['GetInstalledDeviceAttributeViInt32']['return'] = warning_code
        self.patched_library.niModInst_GetExtendedErrorInfo.side_effect = self.side_effects_helper.niModInst_GetExtendedErrorInfo
        self.side_effects_helper['GetExtendedErrorInfo']['errorInfo'] = error_string
        with nimodinst.Session('') as session:
            with warnings.catch_warnings(record=True) as w:
                session.devices[0].chassis_number
                assert len(w) == 1
                assert issubclass(w[0].category, nimodinst.DriverWarning)
                assert error_string in str(w[0].message)
github ni / nimi-python / src / nimodinst / system_tests / test_system_nimodinst.py View on Github external
def test_max_pciexpress_link_width_attribute():
    with nimodinst.Session('') as session:
        assert len(session) > 0, 'Must have hardware for ModInst tests to be valid.'
        assert isinstance(session.devices[0].max_pciexpress_link_width, int)
github ni / nimi-python / src / nimodinst / system_tests / test_system_nimodinst.py View on Github external
def test_string_attribute_error_on_non_existant_device():
    with nimodinst.Session('') as session:
        device = len(session) + 1
        try:
            session.devices[device].slot_number
            assert False
        except IndexError:
            pass
github ni / nimi-python / generated / nimodinst / unit_tests / test_modinst.py View on Github external
def test_get_attribute_vi_string_for_loop_index(self):
        self.patched_library.niModInst_GetInstalledDeviceAttributeViString.side_effect = self.niModInst_GetInstalledDeviceAttributeViString_looping
        self.side_effects_helper['OpenInstalledDevicesSession']['deviceCount'] = self.num_string_devices_looping
        index = 0
        with nimodinst.Session('') as session:
            attr_int = session.devices[index].device_name
            index += 1
            assert(attr_int == self.string_vals_device_looping[self.iteration_device_looping - 1])  # Have to subtract once since it was already incremented in the callback function
github ni / nimi-python / generated / nimodinst / unit_tests / test_modinst.py View on Github external
def test_get_attribute_vi_int32_for_loop_multiple_devices(self):
        self.patched_library.niModInst_GetInstalledDeviceAttributeViInt32.side_effect = self.niModInst_GetInstalledDeviceAttributeViInt32_looping
        self.side_effects_helper['OpenInstalledDevicesSession']['deviceCount'] = self.num_int_devices_looping
        with nimodinst.Session('') as session:
            for d in session:
                attr_int = d.chassis_number
                assert(attr_int == self.int_vals_device_looping[self.iteration_device_looping - 1])  # Have to subtract once since it was already incremented in the callback function
github ni / nimi-python / src / nimodinst / system_tests / test_system_nimodinst.py View on Github external
def test_serial_number_attribute():
    with nimodinst.Session('') as session:
        assert len(session) > 0, 'Must have hardware for ModInst tests to be valid.'
        pattern = r'^[0-9A-F]+$'
        assert isinstance(session.devices[0].serial_number, six.text_type)
        assert (len(session.devices[0].serial_number) == 0) | (re.search(pattern, session.devices[0].serial_number) is not None)  # NI Serial numbers hex unless it is simulated than it is 0
github ni / nimi-python / generated / nimodinst / unit_tests / _matchers.py View on Github external
def __init__(self, expected_size_or_value):
        _BufferMatcher.__init__(self, _visatype.ViInt32, expected_size_or_value)
github ni / nimi-python / generated / nimodinst / unit_tests / _matchers.py View on Github external
def __init__(self, expected_size_or_value):
        _BufferMatcher.__init__(self, _visatype.ViReal64, expected_size_or_value)