Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of tests for Buffer Property #235

Merged
merged 10 commits into from
Apr 4, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/test_buffer_property.py
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"Contains a collection of pytest tests that validates the buffer property."
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
import random

import pytest

import nidaqmx
from nidaqmx.constants import SampleTimingType
from nidaqmx.errors import DaqError
from nidaqmx.tests.helpers import generate_random_seed
from nidaqmx.tests.test_read_write import TestDAQmxIOBase


class TestBufferProperty(TestDAQmxIOBase):
"""Contains a collection of pytest tests that validates the buffer property."""
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved

@pytest.mark.parametrize("seed", [generate_random_seed()])
def test_int32_property(self, any_x_series_device, seed):
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
"""Test for validating int32 attributes in buffer."""
# Reset the pseudorandom number generator with seed.
random.seed(seed)

with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan(any_x_series_device.ai_physical_chans[0].name)
task.timing.samp_timing_type = SampleTimingType.SAMPLE_CLOCK
default_buffer_size = task.in_stream.input_buf_size

# Setting a valid input buffer size of type int32
task.in_stream.input_buf_size = 2000000000
assert task.in_stream.input_buf_size == 2000000000
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved

# Setting a invalid input buffer size greater than int32
try:
task.in_stream.input_buf_size = 4000000000
except DaqError:
assert task.in_stream.input_buf_size == 2000000000
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved

# Resetting input buffer size
del task.in_stream.input_buf_size
assert task.in_stream.input_buf_size == default_buffer_size