def test_insufficient_numpy_write_data(self, x_series_device, seed):
# Reset the pseudorandom number generator with seed.
random.seed(seed)
# Randomly select physical channels to test.
number_of_channels = random.randint(
2, len(x_series_device.ao_physical_chans))
channels_to_test = random.sample(
x_series_device.ao_physical_chans, number_of_channels)
with nidaqmx.Task() as task:
task.ao_channels.add_ao_voltage_chan(
flatten_channel_string([c.name for c in channels_to_test]),
max_val=10, min_val=-10)
number_of_samples = random.randint(1, number_of_channels - 1)
values_to_test = numpy.float64([
random.uniform(-10, 10) for _ in range(number_of_samples)])
with pytest.raises(DaqError) as e:
task.write(values_to_test, auto_start=True)
assert e.value.error_code == -200524
评论列表
文章目录