-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add channel length to tdmsinfo output and improve test coverage (#175)
* Add channel length to tdmsinfo output and improve test coverage * Test debug output in tdmsinfo
- Loading branch information
Showing
4 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,52 @@ | ||
import os | ||
from nptdms.tdmsinfo import tdmsinfo | ||
import sys | ||
from nptdms import tdmsinfo | ||
from nptdms.test.util import GeneratedFile, basic_segment | ||
try: | ||
from unittest.mock import patch | ||
except ImportError: | ||
from mock import patch | ||
|
||
|
||
def test_tdmsinfo(): | ||
def test_tdmsinfo(capsys): | ||
test_file = GeneratedFile() | ||
test_file.add_segment(*basic_segment()) | ||
temp_file = test_file.get_tempfile(delete=False) | ||
try: | ||
temp_file.file.close() | ||
tdmsinfo(temp_file.name) | ||
with patch.object(sys, 'argv', ['tdmsinfo.py', temp_file.name]): | ||
tdmsinfo.main() | ||
captured = capsys.readouterr() | ||
assert "/'Group'/'Channel1'" in captured.out | ||
assert "wf_start_offset" not in captured.out | ||
finally: | ||
os.remove(temp_file.name) | ||
|
||
|
||
def test_tdmsinfo_with_properties(): | ||
def test_tdmsinfo_with_properties(capsys): | ||
test_file = GeneratedFile() | ||
test_file.add_segment(*basic_segment()) | ||
temp_file = test_file.get_tempfile(delete=False) | ||
try: | ||
temp_file.file.close() | ||
tdmsinfo(temp_file.name, show_properties=True) | ||
with patch.object(sys, 'argv', ['tdmsinfo.py', temp_file.name, '--properties']): | ||
tdmsinfo.main() | ||
captured = capsys.readouterr() | ||
assert "/'Group'/'Channel1'" in captured.out | ||
assert "wf_start_offset: 0.0" in captured.out | ||
assert "length: 2" in captured.out | ||
finally: | ||
os.remove(temp_file.name) | ||
|
||
|
||
def test_tdmsinfo_with_debug_output(caplog): | ||
test_file = GeneratedFile() | ||
test_file.add_segment(*basic_segment()) | ||
temp_file = test_file.get_tempfile(delete=False) | ||
try: | ||
temp_file.file.close() | ||
with patch.object(sys, 'argv', ['tdmsinfo.py', temp_file.name, '--debug']): | ||
tdmsinfo.main() | ||
assert "Reading metadata for object /'Group'/'Channel1'" in caplog.text | ||
finally: | ||
os.remove(temp_file.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters