Skip to content

Commit

Permalink
fixup! Add tests for reading and writing digital lines with varying l…
Browse files Browse the repository at this point in the history
…ines per channel
  • Loading branch information
alynch-ni committed Jul 22, 2024
1 parent 1913a6a commit 63db35e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/component/test_stream_writers_do.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ def di_port1_loopback_task(
return task


@pytest.fixture
def di_port2_loopback_task(
generate_task: Callable[[], nidaqmx.Task], real_x_series_device: nidaqmx.system.Device
) -> nidaqmx.Task:
task = generate_task()
task.di_channels.add_di_chan(
real_x_series_device.di_ports[2].name,
line_grouping=LineGrouping.CHAN_FOR_ALL_LINES,
)
_start_di_task(task)
return task


@pytest.fixture
def di_multi_channel_port_loopback_task(
generate_task: Callable[[], nidaqmx.Task], real_x_series_device: nidaqmx.system.Device
Expand Down Expand Up @@ -433,6 +446,8 @@ def test___digital_multi_channel_writer___write_one_sample_multi_line___updates_

def test___digital_multi_channel_writer___write_one_sample_multi_line_jagged___updates_output(
di_port0_loopback_task: nidaqmx.Task,
di_port1_loopback_task: nidaqmx.Task,
di_port2_loopback_task: nidaqmx.Task,
generate_task: Callable[[], nidaqmx.Task],
real_x_series_device: nidaqmx.system.Device,
) -> None:
Expand All @@ -453,6 +468,8 @@ def test___digital_multi_channel_writer___write_one_sample_multi_line_jagged___u
writer.write_one_sample_multi_line(data_to_write)

assert di_port0_loopback_task.read() == datum & 0xFFFFFFFF
assert di_port1_loopback_task.read() == (datum >> 32) & 0xFF
assert di_port2_loopback_task.read() == (datum >> 64) & 0xFF


def test___digital_multi_channel_writer___write_one_sample_multi_line_with_wrong_dtype___raises_error_with_correct_dtype(
Expand Down

0 comments on commit 63db35e

Please sign in to comment.