Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
* ### Resolved Issues
* [37: ai_raw example is bad](https://github.com/ni/nidaqmx-python/issues/37)
* [65: ci_count_edges.py REQUIRES A START COMMAND](https://github.com/ni/nidaqmx-python/issues/65)
* [100: How to clear task and create a new task with same name?](https://github.com/ni/nidaqmx-python/issues/100)
* [102: handle types and daqmx versions](https://github.com/ni/nidaqmx-python/issues/102)
* [117: Error in example](https://github.com/ni/nidaqmx-python/issues/117)
* [131: task.write for COUNTER_OUTPUT - UsageTypeCO.PULSE_FREQUENCY has frequency and duty cycle reversed](https://github.com/ni/nidaqmx-python/issues/131)
Expand Down
2 changes: 1 addition & 1 deletion nidaqmx/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, new_task_name=''):
self._initialize(self._handle)

def __del__(self):
if self._handle is not None:
if self._handle:
warnings.warn(
'Task of name "{0}" was not explicitly closed before it was '
'destructed. Resources on the task device may still be '
Expand Down
23 changes: 23 additions & 0 deletions nidaqmx/tests/test_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

from nidaqmx import Task, DaqError
from nidaqmx.error_codes import DAQmxErrors


class TestTask(object):
"""
Contains a collection of pytest tests that validate duplicate and partially
constructed tasks.
"""

def test_task_duplicate(self):
with Task("task") as t:
with pytest.raises(DaqError) as dupe_exception:
u = Task("task")
# u is now partially constructed, and deleting it should be safe. This previously
# raised an exception which was uncatchable. pytest should fail with that, but it
# doesn't seem to be working. Regardless it will print a warning that contributors
# should see if it regresses.
del(u)
assert dupe_exception.value.error_code == DAQmxErrors.DUPLICATE_TASK.value