diff --git a/tests/component/_task_modules/channels/test_ai_channel.py b/tests/component/_task_modules/channels/test_ai_channel.py index 4d6f73e8..58791cb5 100644 --- a/tests/component/_task_modules/channels/test_ai_channel.py +++ b/tests/component/_task_modules/channels/test_ai_channel.py @@ -32,7 +32,7 @@ from nidaqmx.error_codes import DAQmxErrors from nidaqmx.errors import DaqError from nidaqmx.system import Device -from tests.helpers import chan_with_teds +from tests.helpers import configure_teds # Note: Tests for other channel types will be less complete given that the underlying Python @@ -50,7 +50,7 @@ "units, custom_scale_name", [(VoltageUnits.VOLTS, ""), (VoltageUnits.FROM_CUSTOM_SCALE, "no_scaling_scale")], ) -def test___task__add_ai_voltage_chan___sets_channel_attributes( +def test___task___add_ai_voltage_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, desired_term_config, @@ -77,12 +77,12 @@ def test___task__add_ai_voltage_chan___sets_channel_attributes( assert chan.ai_custom_scale.name == custom_scale_name -def test___task__add_teds_ai_voltage_chan___sets_channel_attributes( +def test___task___add_teds_ai_voltage_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, voltage_teds_file_path, ): - with chan_with_teds(sim_6363_device.ai_physical_chans[0], voltage_teds_file_path) as phys_chan: + with configure_teds(sim_6363_device.ai_physical_chans[0], voltage_teds_file_path) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_voltage_chan( phys_chan.name, ) @@ -101,7 +101,7 @@ def test___task__add_teds_ai_voltage_chan___sets_channel_attributes( (AccelUnits.METERS_PER_SECOND_SQUARED, 0.5, AccelSensitivityUnits.VOLTS_PER_G), ], ) -def test___task__add_ai_accel_4_wire_dc_voltage_chan___sets_channel_attributes( +def test___task___add_ai_accel_4_wire_dc_voltage_chan___sets_channel_attributes( task: Task, sim_charge_device: Device, units, sensitivity, sensitivity_units ): chan: AIChannel = task.ai_channels.add_ai_accel_4_wire_dc_voltage_chan( @@ -124,7 +124,7 @@ def test___task__add_ai_accel_4_wire_dc_voltage_chan___sets_channel_attributes( (AccelUnits.METERS_PER_SECOND_SQUARED, 0.5, AccelSensitivityUnits.VOLTS_PER_G), ], ) -def test___task__add_ai_accel_chan___sets_channel_attributes( +def test___task___add_ai_accel_chan___sets_channel_attributes( task: Task, sim_dsa_device: Device, units, sensitivity, sensitivity_units ): chan: AIChannel = task.ai_channels.add_ai_accel_chan( @@ -147,10 +147,10 @@ def test___task__add_ai_accel_chan___sets_channel_attributes( AccelUnits.METERS_PER_SECOND_SQUARED, ], ) -def test___task__add_teds_ai_accel_chan___sets_channel_attributes( +def test___task___add_teds_ai_accel_chan___sets_channel_attributes( task: Task, sim_dsa_device, accelerometer_teds_file_path, units ): - with chan_with_teds( + with configure_teds( sim_dsa_device.ai_physical_chans[0], accelerometer_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_accel_chan( @@ -176,7 +176,7 @@ def test___task__add_teds_ai_accel_chan___sets_channel_attributes( ), ], ) -def test___task__add_ai_accel_charge_chan___sets_channel_attributes( +def test___task___add_ai_accel_charge_chan___sets_channel_attributes( task: Task, sim_charge_device: Device, units, sensitivity, sensitivity_units ): chan: AIChannel = task.ai_channels.add_ai_accel_charge_chan( @@ -199,7 +199,7 @@ def test___task__add_ai_accel_charge_chan___sets_channel_attributes( (BridgeUnits.MILLIVOLTS_PER_VOLT, BridgeConfiguration.QUARTER_BRIDGE, 120.0), ], ) -def test___task__add_ai_bridge_chan___sets_channel_attributes( +def test___task___add_ai_bridge_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, units, bridge_config, nominal_bridge_resistance ): chan: AIChannel = task.ai_channels.add_ai_bridge_chan( @@ -222,10 +222,10 @@ def test___task__add_ai_bridge_chan___sets_channel_attributes( 2.75, ], ) -def test___task__add_teds_ai_bridge_chan___sets_channel_attributes( +def test___task___add_teds_ai_bridge_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, bridge_teds_file_path, voltage_excit_val ): - with chan_with_teds(sim_bridge_device.ai_physical_chans[0], bridge_teds_file_path) as phys_chan: + with configure_teds(sim_bridge_device.ai_physical_chans[0], bridge_teds_file_path) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_bridge_chan( phys_chan.name, voltage_excit_val=voltage_excit_val ) @@ -241,7 +241,7 @@ def test___task__add_teds_ai_bridge_chan___sets_channel_attributes( @pytest.mark.parametrize("units", [ChargeUnits.COULOMBS, ChargeUnits.PICO_COULOMBS]) -def test___task__add_ai_charge_chan___sets_channel_attributes( +def test___task___add_ai_charge_chan___sets_channel_attributes( task: Task, sim_charge_device: Device, units ): chan: AIChannel = task.ai_channels.add_ai_charge_chan( @@ -263,7 +263,7 @@ def test___task__add_ai_charge_chan___sets_channel_attributes( (CurrentShuntResistorLocation.EXTERNAL, CurrentShuntResistorLocation.EXTERNAL, 99.0), ], ) -def test___task__add_ai_current_chan___sets_channel_attributes( +def test___task___add_ai_current_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, shunt_resistor_loc, @@ -292,7 +292,7 @@ def test___task__add_ai_current_chan___sets_channel_attributes( (CurrentShuntResistorLocation.EXTERNAL, CurrentShuntResistorLocation.EXTERNAL, 99.0), ], ) -def test___task__add_teds_ai_current_chan___sets_channel_attributes( +def test___task___add_teds_ai_current_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, current_teds_file_path, @@ -300,7 +300,7 @@ def test___task__add_teds_ai_current_chan___sets_channel_attributes( expected_shunt_resistor_loc, ext_shunt_resistor_val, ): - with chan_with_teds(sim_6363_device.ai_physical_chans[0], current_teds_file_path) as phys_chan: + with configure_teds(sim_6363_device.ai_physical_chans[0], current_teds_file_path) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_current_chan( phys_chan.name, shunt_resistor_loc=shunt_resistor_loc, @@ -323,7 +323,7 @@ def test___task__add_teds_ai_current_chan___sets_channel_attributes( (CurrentShuntResistorLocation.INTERNAL, CurrentShuntResistorLocation.INTERNAL), ], ) -def test___task__add_ai_current_rms_chan___sets_channel_attributes( +def test___task___add_ai_current_rms_chan___sets_channel_attributes( task: Task, sim_dmm_device: Device, shunt_resistor_loc, expected_shunt_resistor_loc ): chan: AIChannel = task.ai_channels.add_ai_current_rms_chan( @@ -345,7 +345,7 @@ def test___task__add_ai_current_rms_chan___sets_channel_attributes( (BridgeConfiguration.QUARTER_BRIDGE, 120.0, [1.0, 2.0], [-0.5, 0.5]), ], ) -def test___task__add_ai_force_bridge_polynomial_chan___sets_channel_attributes( +def test___task___add_ai_force_bridge_polynomial_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, bridge_config, @@ -375,7 +375,7 @@ def test___task__add_ai_force_bridge_polynomial_chan___sets_channel_attributes( (BridgeConfiguration.QUARTER_BRIDGE, 120.0, [-2.0, 0.0, 2.0], [-200.0, 0.0, 200.0]), ], ) -def test___task__add_ai_force_bridge_table_chan___sets_channel_attributes( +def test___task___add_ai_force_bridge_table_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, bridge_config, @@ -405,7 +405,7 @@ def test___task__add_ai_force_bridge_table_chan___sets_channel_attributes( (BridgeConfiguration.QUARTER_BRIDGE, 120.0, 0.0, 4.0, 0.0, 200.0), ], ) -def test___task__add_ai_force_bridge_two_point_lin_chan___sets_channel_attributes( +def test___task___add_ai_force_bridge_two_point_lin_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, bridge_config, @@ -434,10 +434,10 @@ def test___task__add_ai_force_bridge_two_point_lin_chan___sets_channel_attribute assert chan.ai_bridge_two_point_lin_second_physical_val == second_physical_val -def test___task__add_teds_ai_force_bridge_chan___sets_channel_attributes( +def test___task___add_teds_ai_force_bridge_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, force_bridge_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_bridge_device.ai_physical_chans[0], force_bridge_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_force_bridge_chan( @@ -458,7 +458,7 @@ def test___task__add_teds_ai_force_bridge_chan___sets_channel_attributes( (ForceUnits.POUNDS, 1.25, ForceIEPESensorSensitivityUnits.MILLIVOLTS_PER_POUND), ], ) -def test___task__add_ai_force_iepe_chan___sets_channel_attributes( +def test___task___add_ai_force_iepe_chan___sets_channel_attributes( task: Task, sim_dsa_device: Device, units, sensitivity, sensitivity_units ): chan: AIChannel = task.ai_channels.add_ai_force_iepe_chan( @@ -481,10 +481,10 @@ def test___task__add_ai_force_iepe_chan___sets_channel_attributes( ForceUnits.POUNDS, ], ) -def test___task__add_teds_ai_force_iepe_chan___sets_channel_attributes( +def test___task___add_teds_ai_force_iepe_chan___sets_channel_attributes( task: Task, sim_dsa_device: Device, force_iepe_teds_file_path, units ): - with chan_with_teds( + with configure_teds( sim_dsa_device.ai_physical_chans[0], force_iepe_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_force_iepe_chan( @@ -513,7 +513,7 @@ def test___task__add_teds_ai_force_iepe_chan___sets_channel_attributes( (10.0, 100.0), ], ) -def test___task__add_ai_microphone_chan___sets_channel_attributes( +def test___task___add_ai_microphone_chan___sets_channel_attributes( task: Task, sim_dsa_device: Device, mic_sensitivity, max_snd_press_level ): chan: AIChannel = task.ai_channels.add_ai_microphone_chan( @@ -534,10 +534,10 @@ def test___task__add_ai_microphone_chan___sets_channel_attributes( 100.0, ], ) -def test___task__add_teds_ai_microphone_chan___sets_channel_attributes( +def test___task___add_teds_ai_microphone_chan___sets_channel_attributes( task: Task, sim_dsa_device: Device, microphone_teds_file_path, max_snd_press_level ): - with chan_with_teds( + with configure_teds( sim_dsa_device.ai_physical_chans[0], microphone_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_microphone_chan( @@ -559,7 +559,7 @@ def test___task__add_teds_ai_microphone_chan___sets_channel_attributes( (EddyCurrentProxProbeSensitivityUnits.VOLTS_PER_MIL, 0.2), ], ) -def test___task__add_ai_pos_eddy_curr_prox_probe_chan___sets_channel_attributes( +def test___task___add_ai_pos_eddy_curr_prox_probe_chan___sets_channel_attributes( task: Task, sim_dsa_device: Device, sensitivity_units, sensitivity ): chan: AIChannel = task.ai_channels.add_ai_pos_eddy_curr_prox_probe_chan( @@ -592,7 +592,7 @@ def test___task__add_ai_pos_eddy_curr_prox_probe_chan___sets_channel_attributes( ), ], ) -def test___task__add_ai_pos_lvdt_chan___sets_channel_attributes( +def test___task___add_ai_pos_lvdt_chan___sets_channel_attributes( task: Task, sim_position_device: Device, sensitivity_units, @@ -618,7 +618,7 @@ def test___task__add_ai_pos_lvdt_chan___sets_channel_attributes( assert chan.ai_ac_excit_freq == voltage_excit_freq -def test___task__add_teds_ai_pos_lvdt_chan___sets_channel_attributes( +def test___task___add_teds_ai_pos_lvdt_chan___sets_channel_attributes( task: Task, sim_position_device: Device, lvdt_teds_file_path, @@ -633,7 +633,7 @@ def test___task__add_teds_ai_pos_lvdt_chan___sets_channel_attributes( # Nothing novel here vs. lvdt channels. -def test___task__add_ai_pos_rvdt_chan___sets_channel_attributes(task: Task, sim_position_device): +def test___task___add_ai_pos_rvdt_chan___sets_channel_attributes(task: Task, sim_position_device): chan: AIChannel = task.ai_channels.add_ai_pos_rvdt_chan( sim_position_device.ai_physical_chans[0].name ) @@ -641,7 +641,7 @@ def test___task__add_ai_pos_rvdt_chan___sets_channel_attributes(task: Task, sim_ assert chan.ai_meas_type == UsageTypeAI.POSITION_ANGULAR_RVDT -def test___task__add_teds_ai_pos_rvdt_chan___sets_channel_attributes( +def test___task___add_teds_ai_pos_rvdt_chan___sets_channel_attributes( task: Task, sim_position_device: Device, rvdt_teds_file_path, @@ -662,7 +662,7 @@ def test___task__add_teds_ai_pos_rvdt_chan___sets_channel_attributes( (2.5, 1.0, True), ], ) -def test___task__add_ai_power_chan___sets_channel_attributes( +def test___task___add_ai_power_chan___sets_channel_attributes( task: Task, sim_ts_power_device: Device, voltage_setpoint, current_setpoint, output_enable ): chan: AIChannel = task.ai_channels.add_ai_power_chan( @@ -679,7 +679,7 @@ def test___task__add_ai_power_chan___sets_channel_attributes( # Nothing novel here vs. other bridge-based channels. -def test___task__add_ai_pressure_bridge_polynomial_chan___sets_channel_attributes( +def test___task___add_ai_pressure_bridge_polynomial_chan___sets_channel_attributes( task: Task, sim_bridge_device ): # #482: Default argument values for bridge create channel functions are unusable @@ -693,7 +693,7 @@ def test___task__add_ai_pressure_bridge_polynomial_chan___sets_channel_attribute # Nothing novel here vs. other bridge-based channels. -def test___task__add_ai_pressure_bridge_table_chan___sets_channel_attributes( +def test___task___add_ai_pressure_bridge_table_chan___sets_channel_attributes( task: Task, sim_bridge_device ): # #482: Default argument values for bridge create channel functions are unusable @@ -707,7 +707,7 @@ def test___task__add_ai_pressure_bridge_table_chan___sets_channel_attributes( # Nothing novel here vs. other bridge-based channels. -def test___task__add_ai_pressure_bridge_two_point_lin_chan___sets_channel_attributes( +def test___task___add_ai_pressure_bridge_two_point_lin_chan___sets_channel_attributes( task: Task, sim_bridge_device ): chan: AIChannel = task.ai_channels.add_ai_pressure_bridge_two_point_lin_chan( @@ -717,10 +717,10 @@ def test___task__add_ai_pressure_bridge_two_point_lin_chan___sets_channel_attrib assert chan.ai_meas_type == UsageTypeAI.PRESSURE_BRIDGE -def test___task__add_teds_ai_pressure_bridge_chan___sets_channel_attributes( +def test___task___add_teds_ai_pressure_bridge_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, pressure_bridge_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_bridge_device.ai_physical_chans[0], pressure_bridge_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_pressure_bridge_chan( @@ -741,7 +741,7 @@ def test___task__add_teds_ai_pressure_bridge_chan___sets_channel_attributes( (ResistanceConfiguration.THREE_WIRE), ], ) -def test___task__add_ai_resistance_chan___sets_channel_attributes( +def test___task___add_ai_resistance_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, resistance_config ): chan: AIChannel = task.ai_channels.add_ai_resistance_chan( @@ -759,10 +759,10 @@ def test___task__add_ai_resistance_chan___sets_channel_attributes( (ResistanceConfiguration.THREE_WIRE), ], ) -def test___task__add_teds_ai_resistance_chan___sets_channel_attributes( +def test___task___add_teds_ai_resistance_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, resistance_teds_file_path, resistance_config ): - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans[0], resistance_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_resistance_chan( @@ -775,7 +775,7 @@ def test___task__add_teds_ai_resistance_chan___sets_channel_attributes( # Rosette is very complicated, so I'm not parametrizing this test. -def test___task__add_ai_rosette_strain_gage_chan___sets_channel_attributes( +def test___task___add_ai_rosette_strain_gage_chan___sets_channel_attributes( task: Task, sim_bridge_device ): # #483: add_ai_rosette_strain_gage_chan parameter rosette_meas_types has the wrong type @@ -796,7 +796,7 @@ def test___task__add_ai_rosette_strain_gage_chan___sets_channel_attributes( (RTDType.PT_3851, ResistanceConfiguration.THREE_WIRE), ], ) -def test___task__add_ai_rtd_chan___sets_channel_attributes( +def test___task___add_ai_rtd_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, rtd_type, resistance_config ): chan: AIChannel = task.ai_channels.add_ai_rtd_chan( @@ -817,10 +817,10 @@ def test___task__add_ai_rtd_chan___sets_channel_attributes( ResistanceConfiguration.THREE_WIRE, ], ) -def test___task__add_teds_ai_rtd_chan___sets_channel_attributes( +def test___task___add_teds_ai_rtd_chan___sets_channel_attributes( task: Task, sim_6363_device: Device, rtd_teds_file_path, resistance_config ): - with chan_with_teds(sim_6363_device.ai_physical_chans[0], rtd_teds_file_path) as phys_chan: + with configure_teds(sim_6363_device.ai_physical_chans[0], rtd_teds_file_path) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_rtd_chan( phys_chan.name, resistance_config=resistance_config ) @@ -842,7 +842,7 @@ def test___task__add_teds_ai_rtd_chan___sets_channel_attributes( (StrainGageBridgeType.QUARTER_BRIDGE_I, 1.1, 120.0), ], ) -def test___task__add_ai_strain_gage_chan___sets_channel_attributes( +def test___task___add_ai_strain_gage_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, strain_config, gage_factor, nominal_gage_resistance ): chan: AIChannel = task.ai_channels.add_ai_strain_gage_chan( @@ -858,10 +858,10 @@ def test___task__add_ai_strain_gage_chan___sets_channel_attributes( assert chan.ai_bridge_nom_resistance == nominal_gage_resistance -def test___task__add_ai_teds_strain_gage_chan___sets_channel_attributes( +def test___task___add_ai_teds_strain_gage_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, strain_gage_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_bridge_device.ai_physical_chans[0], strain_gage_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_strain_gage_chan( @@ -876,7 +876,7 @@ def test___task__add_ai_teds_strain_gage_chan___sets_channel_attributes( assert chan.ai_bridge_nom_resistance == pytest.approx(120.0, abs=0.01) -def test___task__add_ai_temp_built_in_sensor_chan___sets_channel_attributes( +def test___task___add_ai_temp_built_in_sensor_chan___sets_channel_attributes( task: Task, sim_6363_device ): chan: AIChannel = task.ai_channels.add_ai_temp_built_in_sensor_chan( @@ -893,7 +893,7 @@ def test___task__add_ai_temp_built_in_sensor_chan___sets_channel_attributes( (ThermocoupleType.K, CJCSource.BUILT_IN, 0.0), ], ) -def test___task__add_ai_thrmcpl_chan___sets_channel_attributes( +def test___task___add_ai_thrmcpl_chan___sets_channel_attributes( task: Task, sim_temperature_device: Device, thermocouple_type, cjc_source, cjc_val ): chan: AIChannel = task.ai_channels.add_ai_thrmcpl_chan( @@ -916,10 +916,10 @@ def test___task__add_ai_thrmcpl_chan___sets_channel_attributes( (CJCSource.BUILT_IN, 0.0), ], ) -def test___task__add_teds_ai_thrmcpl_chan___sets_channel_attributes( +def test___task___add_teds_ai_thrmcpl_chan___sets_channel_attributes( task: Task, sim_temperature_device: Device, thermocouple_teds_file_path, cjc_source, cjc_val ): - with chan_with_teds( + with configure_teds( sim_temperature_device.ai_physical_chans[0], thermocouple_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_thrmcpl_chan( @@ -943,7 +943,7 @@ def test___task__add_teds_ai_thrmcpl_chan___sets_channel_attributes( (ResistanceConfiguration.FOUR_WIRE, 0.2, 0.3, 0.4), ], ) -def test___task__add_ai_thrmstr_chan_iex___sets_channel_attributes( +def test___task___add_ai_thrmstr_chan_iex___sets_channel_attributes( task: Task, sim_6363_device: Device, resistance_config, a, b, c ): chan: AIChannel = task.ai_channels.add_ai_thrmstr_chan_iex( @@ -968,10 +968,10 @@ def test___task__add_ai_thrmstr_chan_iex___sets_channel_attributes( ResistanceConfiguration.FOUR_WIRE, ], ) -def test___task__add_teds_ai_thrmstr_chan_iex___sets_channel_attributes( +def test___task___add_teds_ai_thrmstr_chan_iex___sets_channel_attributes( task: Task, sim_6363_device: Device, thermistor_iex_teds_file_path, resistance_config ): - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans[0], thermistor_iex_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_thrmstr_chan_iex( @@ -995,7 +995,7 @@ def test___task__add_teds_ai_thrmstr_chan_iex___sets_channel_attributes( (TemperatureUnits.DEG_F, ResistanceConfiguration.FOUR_WIRE), ], ) -def test___task__add_ai_thrmstr_chan_vex___sets_channel_attributes( +def test___task___add_ai_thrmstr_chan_vex___sets_channel_attributes( task: Task, sim_6363_device: Device, units, resistance_config ): chan: AIChannel = task.ai_channels.add_ai_thrmstr_chan_vex( @@ -1014,10 +1014,10 @@ def test___task__add_ai_thrmstr_chan_vex___sets_channel_attributes( (TemperatureUnits.DEG_F, ResistanceConfiguration.FOUR_WIRE), ], ) -def test___task__add_teds_ai_thrmstr_chan_vex___sets_channel_attributes( +def test___task___add_teds_ai_thrmstr_chan_vex___sets_channel_attributes( task: Task, sim_6363_device: Device, thermistor_vex_teds_file_path, units, resistance_config ): - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans[0], thermistor_vex_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_thrmstr_chan_vex( @@ -1037,7 +1037,7 @@ def test___task__add_teds_ai_thrmstr_chan_vex___sets_channel_attributes( # Nothing novel here vs. other bridge-based channels. -def test___task__add_ai_torque_bridge_polynomial_chan___sets_channel_attributes( +def test___task___add_ai_torque_bridge_polynomial_chan___sets_channel_attributes( task: Task, sim_bridge_device ): # #482: Default argument values for bridge create channel functions are unusable @@ -1051,7 +1051,7 @@ def test___task__add_ai_torque_bridge_polynomial_chan___sets_channel_attributes( # Nothing novel here vs. other bridge-based channels. -def test___task__add_ai_torque_bridge_table_chan___sets_channel_attributes( +def test___task___add_ai_torque_bridge_table_chan___sets_channel_attributes( task: Task, sim_bridge_device ): # #482: Default argument values for bridge create channel functions are unusable @@ -1065,7 +1065,7 @@ def test___task__add_ai_torque_bridge_table_chan___sets_channel_attributes( # Nothing novel here vs. other bridge-based channels. -def test___task__add_ai_torque_bridge_two_point_lin_chan___sets_channel_attributes( +def test___task___add_ai_torque_bridge_two_point_lin_chan___sets_channel_attributes( task: Task, sim_bridge_device ): chan: AIChannel = task.ai_channels.add_ai_torque_bridge_two_point_lin_chan( @@ -1075,10 +1075,10 @@ def test___task__add_ai_torque_bridge_two_point_lin_chan___sets_channel_attribut assert chan.ai_meas_type == UsageTypeAI.TORQUE_BRIDGE -def test___task__add_teds_ai_torque_bridge_chan___sets_channel_attributes( +def test___task___add_teds_ai_torque_bridge_chan___sets_channel_attributes( task: Task, sim_bridge_device: Device, torque_bridge_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_bridge_device.ai_physical_chans[0], torque_bridge_teds_file_path ) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_torque_bridge_chan( @@ -1093,7 +1093,7 @@ def test___task__add_teds_ai_torque_bridge_chan___sets_channel_attributes( # Nothing novel here vs. other iepe channels. -def test___task__add_ai_velocity_iepe_chan___sets_channel_attributes(task: Task, sim_dsa_device): +def test___task___add_ai_velocity_iepe_chan___sets_channel_attributes(task: Task, sim_dsa_device): chan: AIChannel = task.ai_channels.add_ai_velocity_iepe_chan( sim_dsa_device.ai_physical_chans[0].name ) @@ -1108,7 +1108,7 @@ def test___task__add_ai_velocity_iepe_chan___sets_channel_attributes(task: Task, (-2.0, 2.0, BridgeConfiguration.HALF_BRIDGE, ExcitationSource.EXTERNAL, 5.0, True), ], ) -def test___task__add_ai_voltage_chan_with_excit___sets_channel_attributes( +def test___task___add_ai_voltage_chan_with_excit___sets_channel_attributes( task: Task, sim_6363_device: Device, min_val, @@ -1137,12 +1137,12 @@ def test___task__add_ai_voltage_chan_with_excit___sets_channel_attributes( assert chan.ai_excit_use_for_scaling == use_excit_for_scaling -def test___task__add_teds_ai_voltage_chan_with_excit___sets_channel_attributes( +def test___task___add_teds_ai_voltage_chan_with_excit___sets_channel_attributes( task: Task, sim_bridge_device: Device, bridge_teds_file_path, ): - with chan_with_teds(sim_bridge_device.ai_physical_chans[0], bridge_teds_file_path) as phys_chan: + with configure_teds(sim_bridge_device.ai_physical_chans[0], bridge_teds_file_path) as phys_chan: chan: AIChannel = task.ai_channels.add_teds_ai_voltage_chan_with_excit( phys_chan.name, min_val=-1.25, @@ -1160,7 +1160,7 @@ def test___task__add_teds_ai_voltage_chan_with_excit___sets_channel_attributes( assert chan.ai_excit_use_for_scaling -def test___task__add_ai_voltage_rms_chan___sets_channel_attributes(task: Task, sim_dmm_device): +def test___task___add_ai_voltage_rms_chan___sets_channel_attributes(task: Task, sim_dmm_device): chan: AIChannel = task.ai_channels.add_ai_voltage_rms_chan( f"{sim_dmm_device.name}/dmm", min_val=0.0, max_val=1.0 ) diff --git a/tests/component/system/test_physical_channel_properties.py b/tests/component/system/test_physical_channel_properties.py index 679b3c91..3b5ec559 100644 --- a/tests/component/system/test_physical_channel_properties.py +++ b/tests/component/system/test_physical_channel_properties.py @@ -5,7 +5,7 @@ from nidaqmx.constants import TerminalConfiguration, UsageTypeAI from nidaqmx.error_codes import DAQmxErrors from nidaqmx.system import PhysicalChannel -from tests.helpers import chan_with_teds +from tests.helpers import configure_teds def test___constructed_physical_channel___get_property___returns_value(init_kwargs): @@ -36,7 +36,7 @@ def test___physical_channel_with_teds___get_bit_stream___returns_configured_valu ): expected_value = numpy.array(VALUES_IN_TED, dtype=numpy.uint8) - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans["ai0"], voltage_teds_file_path ) as phys_chan: assert (phys_chan.teds_bit_stream == expected_value).all() @@ -60,7 +60,7 @@ def test___physical_channel___get_int32_array_property___returns_default_value( def test___physical_channel_with_teds___get_string_property___returns_configured_value( sim_6363_device, voltage_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans["ai0"], voltage_teds_file_path ) as phys_chan: assert phys_chan.teds_version_letter == "A" @@ -69,7 +69,7 @@ def test___physical_channel_with_teds___get_string_property___returns_configured def test___physical_channel_with_teds___get_uint32_array_property___returns_configured_value( sim_6363_device, voltage_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans["ai0"], voltage_teds_file_path ) as phys_chan: assert phys_chan.teds_template_ids == [30] @@ -78,7 +78,7 @@ def test___physical_channel_with_teds___get_uint32_array_property___returns_conf def test___physical_channel_with_teds___get_uint32_property___returns_configured_value( sim_6363_device, voltage_teds_file_path ): - with chan_with_teds( + with configure_teds( sim_6363_device.ai_physical_chans["ai0"], voltage_teds_file_path ) as phys_chan: assert phys_chan.teds_mfg_id == 17 diff --git a/tests/conftest.py b/tests/conftest.py index 554a970e..4c0a052b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -513,110 +513,110 @@ def interpreter(system: nidaqmx.system.System) -> BaseInterpreter: @pytest.fixture -def teds_assets_directory(test_assets_directory): +def teds_assets_directory(test_assets_directory) -> pathlib.Path: """Returns the path to TEDS assets.""" - return pathlib.Path(test_assets_directory, "teds") + return pathlib.Path(test_assets_directory) / "teds" @pytest.fixture -def voltage_teds_file_path(teds_assets_directory): +def voltage_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "Voltage.ted") + return pathlib.Path(teds_assets_directory) / "Voltage.ted" @pytest.fixture -def accelerometer_teds_file_path(teds_assets_directory): +def accelerometer_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "Accelerometer.ted") + return pathlib.Path(teds_assets_directory) / "Accelerometer.ted" @pytest.fixture -def bridge_teds_file_path(teds_assets_directory): +def bridge_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" # Our normal bridge sensor TEDS file is incompatible with most devices. It # has a 1ohm bridge resistance. - return pathlib.Path(teds_assets_directory, "forcebridge.ted") + return pathlib.Path(teds_assets_directory) / "forcebridge.ted" @pytest.fixture -def force_bridge_teds_file_path(teds_assets_directory): +def force_bridge_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "forcebridge.ted") + return pathlib.Path(teds_assets_directory) / "forcebridge.ted" @pytest.fixture -def current_teds_file_path(teds_assets_directory): +def current_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "Current.ted") + return pathlib.Path(teds_assets_directory) / "Current.ted" @pytest.fixture -def force_iepe_teds_file_path(teds_assets_directory): +def force_iepe_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "ForceSensor.ted") + return pathlib.Path(teds_assets_directory) / "ForceSensor.ted" @pytest.fixture -def microphone_teds_file_path(teds_assets_directory): +def microphone_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "Microphone.ted") + return pathlib.Path(teds_assets_directory) / "Microphone.ted" @pytest.fixture -def lvdt_teds_file_path(teds_assets_directory): +def lvdt_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "LVDT.ted") + return pathlib.Path(teds_assets_directory) / "LVDT.ted" @pytest.fixture -def rvdt_teds_file_path(teds_assets_directory): +def rvdt_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "RVDT.ted") + return pathlib.Path(teds_assets_directory) / "RVDT.ted" @pytest.fixture -def pressure_bridge_teds_file_path(teds_assets_directory): +def pressure_bridge_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "pressurebridge.ted") + return pathlib.Path(teds_assets_directory) / "pressurebridge.ted" @pytest.fixture -def torque_bridge_teds_file_path(teds_assets_directory): +def torque_bridge_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "torquebridge.ted") + return pathlib.Path(teds_assets_directory) / "torquebridge.ted" @pytest.fixture -def resistance_teds_file_path(teds_assets_directory): +def resistance_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "Resistance.ted") + return pathlib.Path(teds_assets_directory) / "Resistance.ted" @pytest.fixture -def rtd_teds_file_path(teds_assets_directory): +def rtd_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "TempRTD.ted") + return pathlib.Path(teds_assets_directory) / "TempRTD.ted" @pytest.fixture -def strain_gage_teds_file_path(teds_assets_directory): +def strain_gage_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "StrainGage.ted") + return pathlib.Path(teds_assets_directory) / "StrainGage.ted" @pytest.fixture -def thermocouple_teds_file_path(teds_assets_directory): +def thermocouple_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "TempTC.ted") + return pathlib.Path(teds_assets_directory) / "TempTC.ted" @pytest.fixture -def thermistor_iex_teds_file_path(teds_assets_directory): +def thermistor_iex_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "ThermistorIex.ted") + return pathlib.Path(teds_assets_directory) / "ThermistorIex.ted" @pytest.fixture -def thermistor_vex_teds_file_path(teds_assets_directory): +def thermistor_vex_teds_file_path(teds_assets_directory) -> pathlib.Path: """Returns a TEDS file path.""" - return pathlib.Path(teds_assets_directory, "ThermistorVex.ted") + return pathlib.Path(teds_assets_directory) / "ThermistorVex.ted" diff --git a/tests/helpers.py b/tests/helpers.py index 3f36e79e..ea15ec78 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -2,6 +2,7 @@ import contextlib import pathlib +from typing import Generator from nidaqmx.system.physical_channel import PhysicalChannel @@ -18,7 +19,9 @@ def generate_random_seed(): @contextlib.contextmanager -def chan_with_teds(phys_chan: PhysicalChannel, teds_file_path: pathlib.Path): +def configure_teds( + phys_chan: PhysicalChannel, teds_file_path: pathlib.Path +) -> Generator[PhysicalChannel, None, None]: """Yields a physical channel with TEDS configured and then clears it after the test is done.""" phys_chan.configure_teds(str(teds_file_path)) try: diff --git a/tests/legacy/test_teds.py b/tests/legacy/test_teds.py index 8277937b..83cc37b0 100644 --- a/tests/legacy/test_teds.py +++ b/tests/legacy/test_teds.py @@ -4,7 +4,7 @@ import pytest from nidaqmx.constants import TEDSUnits, TerminalConfiguration -from tests.helpers import chan_with_teds, generate_random_seed +from tests.helpers import configure_teds, generate_random_seed class TestTEDS: @@ -19,7 +19,7 @@ def test_create_teds_ai_voltage_chan(self, task, sim_6363_device, seed, voltage_ # Reset the pseudorandom number generator with seed. random.seed(seed) - with chan_with_teds( + with configure_teds( random.choice(sim_6363_device.ai_physical_chans), voltage_teds_file_path ) as ai_phys_chan: assert ai_phys_chan.teds_mfg_id == 17