Skip to content
Open
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
58 changes: 28 additions & 30 deletions tests/test_vxi11.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
#!/usr/bin/env python

import nose
from nose.tools import eq_
from vxi11.vxi11 import parse_visa_resource_string


def test_parse_visa_resource_string():
f = parse_visa_resource_string

res = f('TCPIP::10.0.0.1::INSTR')
eq_(res['type'], 'TCPIP')
eq_(res['prefix'], 'TCPIP')
eq_(res['arg1'], '10.0.0.1')
eq_(res['suffix'], 'INSTR')
assert res['type'] == 'TCPIP'
assert res['prefix'] == 'TCPIP'
assert res['arg1'] == '10.0.0.1'
assert res['suffix'] == 'INSTR'

res = f('TCPIP0::10.0.0.1::INSTR')
eq_(res['type'], 'TCPIP')
eq_(res['prefix'], 'TCPIP0')
eq_(res['arg1'], '10.0.0.1')
eq_(res['suffix'], 'INSTR')
assert res['type'] == 'TCPIP'
assert res['prefix'] == 'TCPIP0'
assert res['arg1'] == '10.0.0.1'
assert res['suffix'] == 'INSTR'

res = f('TCPIP::10.0.0.1::gpib,5::INSTR')
eq_(res['type'], 'TCPIP')
eq_(res['prefix'], 'TCPIP')
eq_(res['arg1'], '10.0.0.1')
eq_(res['suffix'], 'INSTR')
assert res['type'] == 'TCPIP'
assert res['prefix'] == 'TCPIP'
assert res['arg1'] == '10.0.0.1'
assert res['suffix'] == 'INSTR'

res = f('TCPIP0::10.0.0.1::gpib,5::INSTR')
eq_(res['type'], 'TCPIP')
eq_(res['prefix'], 'TCPIP0')
eq_(res['arg1'], '10.0.0.1')
eq_(res['arg2'], 'gpib,5')
eq_(res['suffix'], 'INSTR')
assert res['type'] == 'TCPIP'
assert res['prefix'] == 'TCPIP0'
assert res['arg1'] == '10.0.0.1'
assert res['arg2'] == 'gpib,5'
assert res['suffix'] == 'INSTR'

res = f('TCPIP0::10.0.0.1::usb0::INSTR')
eq_(res['type'], 'TCPIP')
eq_(res['prefix'], 'TCPIP0')
eq_(res['arg1'], '10.0.0.1')
eq_(res['arg2'], 'usb0')
eq_(res['suffix'], 'INSTR')
assert res['type'] == 'TCPIP'
assert res['prefix'] == 'TCPIP0'
assert res['arg1'] == '10.0.0.1'
assert res['arg2'] == 'usb0'
assert res['suffix'] == 'INSTR'

res = f('TCPIP0::10.0.0.1::usb0[1234::5678::MYSERIAL::0]::INSTR')
eq_(res['type'], 'TCPIP')
eq_(res['prefix'], 'TCPIP0')
eq_(res['arg1'], '10.0.0.1')
eq_(res['arg2'], 'usb0[1234::5678::MYSERIAL::0]')
eq_(res['suffix'], 'INSTR')

assert res['type'] == 'TCPIP'
assert res['prefix'] == 'TCPIP0'
assert res['arg1'] == '10.0.0.1'
assert res['arg2'] == 'usb0[1234::5678::MYSERIAL::0]'
assert res['suffix'] == 'INSTR'
2 changes: 1 addition & 1 deletion vxi11/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.9'
__version__ = '0.9.1'
4 changes: 2 additions & 2 deletions vxi11/vxi11.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def parse_visa_resource_string(resource_string):
# TCPIP0::10.0.0.1::gpib,5::INSTR
# TCPIP0::10.0.0.1::usb0::INSTR
# TCPIP0::10.0.0.1::usb0[1234::5678::MYSERIAL::0]::INSTR
m = re.match('^(?P<prefix>(?P<type>TCPIP)\d*)(::(?P<arg1>[^\s:]+))'
'(::(?P<arg2>[^\s:]+(\[.+\])?))?(::(?P<suffix>INSTR))$',
m = re.match(r'^(?P<prefix>(?P<type>TCPIP)\d*)(::(?P<arg1>[^\s:]+))'
r'(::(?P<arg2>[^\s:]+(\[.+\])?))?(::(?P<suffix>INSTR))$',
resource_string, re.I)

if m is not None:
Expand Down