Skip to content

Commit

Permalink
Moved vpp43 to wrapper subpackage.
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Feb 2, 2014
1 parent ff8cfad commit a9edf52
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 86 deletions.
10 changes: 5 additions & 5 deletions pyvisa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"""

from __future__ import division, unicode_literals, print_function, absolute_import

import os
import sys
import logging
import pkg_resources
import subprocess
import ConfigParser

from . import vpp43
import pkg_resources

import ConfigParser
from pyvisa.wrapper import functions

logger = logging.getLogger('pyvisa')
logger.addHandler(logging.NullHandler)
Expand All @@ -46,4 +46,4 @@
except ConfigParser.Error:
pass
else:
vpp43.visa_library.load_library(_visa_library_path)
functions.visa_library.load_library(_visa_library_path)
38 changes: 19 additions & 19 deletions pyvisa/testsuite/test_visa.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
#

from __future__ import division, unicode_literals, print_function, absolute_import
import collections
import struct

from pyvisa import visa
from pyvisa.visa import InvalidBinaryFormat
import pytest
from mock import Mock
import collections
import struct

def packfloats1(fmt, floats):
data = b''.join(struct.pack(fmt, num) for num in floats)
Expand All @@ -57,8 +57,8 @@ def pytest_funcarg__instrument(self, request):
'interface_type',
visa.VI_INTF_GPIB)
my_attr = MyAttribute()
monkeypatch.setattr(visa.vpp43, "get_attribute", my_attr.get_attribute)
monkeypatch.setattr(visa.vpp43, "set_attribute", my_attr.set_attribute)
monkeypatch.setattr(pyvisa.wrapper.vpp43, "get_attribute", my_attr.get_attribute)
monkeypatch.setattr(pyvisa.wrapper.vpp43, "set_attribute", my_attr.set_attribute)
return visa.Instrument(1)

def test_repr(self, instrument):
Expand All @@ -74,7 +74,7 @@ def test_repr(self, instrument):
(b"hi there\r\n", b"hi there\r\n")])
def test_write(self, monkeypatch, instrument, message, expected):
my_write = Mock()
monkeypatch.setattr(visa.vpp43, 'write', my_write)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'write', my_write)
instrument.write(message)
print(repr(instrument.term_chars))
my_write.assert_called_with(0, expected)
Expand All @@ -87,7 +87,7 @@ def test_write(self, monkeypatch, instrument, message, expected):
def test_write_termchars_set(self, monkeypatch, instrument,
message, expected):
my_write = Mock()
monkeypatch.setattr(visa.vpp43, 'write', my_write)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'write', my_write)
instrument.term_chars = b'\n'
instrument.write(message)
my_write.assert_called_with(0, expected)
Expand All @@ -100,7 +100,7 @@ def test_write_termchars_set(self, monkeypatch, instrument,
def test_write_delay_set(self, monkeypatch, instrument, message, expected):
my_write = Mock()
my_sleep = Mock()
monkeypatch.setattr(visa.vpp43, 'write', my_write)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'write', my_write)
monkeypatch.setattr(visa.time, 'sleep', my_sleep)
instrument.delay = 1
instrument.write(message)
Expand Down Expand Up @@ -140,16 +140,16 @@ def test_send_end(self, instrument, value):
def test_read_raw(self, monkeypatch, instrument):
my_read = Mock(return_value=b'some bytes\r\n')
my_get_status = Mock(side_effect=[visa.VI_SUCCESS_MAX_CNT, 0])
monkeypatch.setattr(visa.vpp43, 'read', my_read)
monkeypatch.setattr(visa.vpp43, 'get_status', my_get_status)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'read', my_read)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'get_status', my_get_status)
result = instrument.read_raw()
assert result == b'some bytes\r\nsome bytes\r\n'

def test_read(self, monkeypatch, instrument):
my_read = Mock(return_value=b'some bytes\r\n')
my_get_status = Mock(side_effect=[visa.VI_SUCCESS_MAX_CNT, 0])
monkeypatch.setattr(visa.vpp43, 'read', my_read)
monkeypatch.setattr(visa.vpp43, 'get_status', my_get_status)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'read', my_read)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'get_status', my_get_status)
result = instrument.read()
assert result == b'some bytes\r\nsome bytes'

Expand Down Expand Up @@ -204,8 +204,8 @@ def test_read_values(self, monkeypatch, instrument,
format, input, expected):
my_read = Mock(return_value=input)
my_get_status = Mock(return_value=0)
monkeypatch.setattr(visa.vpp43, 'read', my_read)
monkeypatch.setattr(visa.vpp43, 'get_status', my_get_status)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'read', my_read)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'get_status', my_get_status)
result = instrument.read_values(format)
assert result == expected

Expand All @@ -220,8 +220,8 @@ def test_read_values_errors(self, monkeypatch, instrument,
format, input, expected_exception):
my_read = Mock(return_value=input)
my_get_status = Mock(return_value=0)
monkeypatch.setattr(visa.vpp43, 'read', my_read)
monkeypatch.setattr(visa.vpp43, 'get_status', my_get_status)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'read', my_read)
monkeypatch.setattr(pyvisa.wrapper.vpp43, 'get_status', my_get_status)
with pytest.raises(expected_exception):
instrument.read_values(format)

Expand All @@ -237,8 +237,8 @@ def pytest_funcarg__instrument(self, request):
visa.VI_INTF_GPIB)
monkeypatch.setattr(visa.GpibInstrument, 'stb', 0x40)
my_attr = MyAttribute()
monkeypatch.setattr(visa.vpp43, "get_attribute", my_attr.get_attribute)
monkeypatch.setattr(visa.vpp43, "set_attribute", my_attr.set_attribute)
monkeypatch.setattr(pyvisa.wrapper.vpp43, "get_attribute", my_attr.get_attribute)
monkeypatch.setattr(pyvisa.wrapper.vpp43, "set_attribute", my_attr.set_attribute)
return visa.GpibInstrument(1)

@pytest.mark.parametrize('timeout', [None, 0, 25, 4294967])
Expand Down Expand Up @@ -266,8 +266,8 @@ def pytest_funcarg__instrument(self, request):
'interface_type',
visa.VI_INTF_ASRL)
my_attr = MyAttribute()
monkeypatch.setattr(visa.vpp43, "get_attribute", my_attr.get_attribute)
monkeypatch.setattr(visa.vpp43, "set_attribute", my_attr.set_attribute)
monkeypatch.setattr(pyvisa.wrapper.vpp43, "get_attribute", my_attr.get_attribute)
monkeypatch.setattr(pyvisa.wrapper.vpp43, "set_attribute", my_attr.set_attribute)
return visa.SerialInstrument(1)

def test_term_chars_default(self, instrument):
Expand Down
Loading

0 comments on commit a9edf52

Please sign in to comment.