Skip to content

Commit

Permalink
Merge pull request #1 from loft-orbital/fix/deprecation-warnings
Browse files Browse the repository at this point in the history
fix: address deprecation warnings
  • Loading branch information
matt-loft authored Sep 14, 2023
2 parents cc4671d + a8ad324 commit eabc4de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
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'
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

0 comments on commit eabc4de

Please sign in to comment.