1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
Author: Michael R. Crusoe <crusoe@debian.org>
Description: Skip tests that require pyvisa_sim
Forwarded: not-needed
It is not yet packaged for Debian
--- python-pymeasure.orig/tests/instruments/test_connection_configuration.py
+++ python-pymeasure/tests/instruments/test_connection_configuration.py
@@ -22,12 +22,15 @@
# THE SOFTWARE.
#
+import importlib
+
import pytest
import serial
from pymeasure.adapters import SerialAdapter, VISAAdapter
from pymeasure.instruments import Instrument
+is_pyvisa_sim_not_installed = not bool(importlib.util.find_spec("pyvisa_sim"))
# As an instrument contributor, I want to define default connection settings for my
# instrument with a minimum of boiler-plate. These settings should be easily
@@ -68,18 +71,27 @@
# real instrument, through.
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_serial_default_settings():
"""As a user, I want to simply connect to an instrument using default settings"""
instr = MultiprotocolInstrument(adapter='ASRL1::INSTR', visa_library='@sim')
assert instr.adapter.connection.baud_rate == 2400
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_serial_custom_baud_rate_is_set():
"""As a user, I want to easily override default settings to fit my needs"""
instr = MultiprotocolInstrument(adapter='ASRL1::INSTR', baud_rate=115200, visa_library='@sim')
assert instr.adapter.connection.baud_rate == 115200
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_connections_use_tcpip():
"""As a user, I want to be free to choose which connection to use (e.g. serial-over RS-232,
USB, TCP/IP) should an instrument support more than one
@@ -90,6 +102,9 @@
assert hasattr(instr.adapter.connection, 'control_ren')
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_connections_use_gpib():
"""As a user, I want to be free to choose which connection to use (e.g. serial-over RS-232,
USB, TCP/IP) should an instrument support more than one
@@ -120,6 +135,9 @@
assert instr.adapter.connection.baudrate == 9600 # default of serial
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_use_separate_VISAAdapter():
"""As a user, I want to be able to supply my own VISAAdpter with my settings
"""
@@ -130,6 +148,9 @@
assert instr.adapter.connection.baud_rate == 1200
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_incorrect_arg_is_flagged():
"""As a user or instrument contributor that used an incorrect/invalid (kw)arg,
I want to be alerted to that fact.
@@ -138,6 +159,9 @@
_ = MultiprotocolInstrument(adapter='ASRL1::INSTR', bitrate=1234, visa_library='@sim')
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_incorrect_interface_type_is_flagged():
"""As a user or instrument contributor that used an incorrect/invalid interface type,
I want to be alerted to that fact.
@@ -153,6 +177,9 @@
_ = WrongInterfaceInstrument(adapter='ASRL1::INSTR', visa_library='@sim')
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_improper_arg_is_flagged():
"""As a user or instrument contributor that used a kwarg that is inappropriate for the present
connection, I want to be alerted to that fact.
@@ -162,6 +189,9 @@
visa_library='@sim')
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_common_kwargs_are_retained():
instr1 = MultiprotocolInstrument(adapter='ASRL1::INSTR', visa_library='@sim')
assert instr1.adapter.connection.timeout == 1500
@@ -169,6 +199,9 @@
assert instr2.adapter.connection.timeout == 1500
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_distinct_interface_specific_defaults():
"""As an instrument implementor, I can easily prescribe default settings
that are different between interfaces.
@@ -179,6 +212,9 @@
assert instr2.adapter.connection.read_termination == '\r'
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_modified_non_signature_kwargs_are_retained():
instr1 = MultiprotocolInstrument(adapter='ASRL1::INSTR', timeout=3000, visa_library='@sim')
assert instr1.adapter.connection.timeout == 3000
@@ -186,6 +222,9 @@
assert instr2.adapter.connection.timeout == 3000
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_override_interface_specific_defaults():
"""As as user, I want to be able to override interface-specific hardcoded defaults.
"""
--- python-pymeasure.orig/tests/instruments/test_instrument.py
+++ python-pymeasure/tests/instruments/test_instrument.py
@@ -22,7 +22,7 @@
# THE SOFTWARE.
#
-
+import importlib
import time
from unittest import mock
@@ -34,6 +34,8 @@
from pymeasure.instruments.fakes import FakeInstrument
from pymeasure.instruments.validators import truncated_range
+is_pyvisa_sim_not_installed = not bool(importlib.util.find_spec("pyvisa_sim"))
+
class GenericInstrument(FakeInstrument):
# Use truncated_range as this easily lets us test for the range boundaries
@@ -117,6 +119,9 @@
assert inst.SCPI is True
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
@pytest.mark.parametrize("adapter", (("COM1", 87, "USB")))
def test_init_visa(adapter):
Instrument(adapter, "def", visa_library="@sim")
@@ -129,11 +134,17 @@
Instrument("abc", "def", visa_library="@xyz")
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_init_includeSCPI_implicit_warning():
with pytest.warns(FutureWarning, match="includeSCPI"):
Instrument("COM1", "def", visa_library="@sim")
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_init_includeSCPI_explicit_warning():
with pytest.warns(FutureWarning, match="includeSCPI"):
Instrument("COM1", "def", visa_library="@sim", includeSCPI=True)
@@ -145,6 +156,9 @@
assert inst.values("x5x") == [5]
+@pytest.mark.skipif(
+ is_pyvisa_sim_not_installed, reason="PyVISA tests require the pyvisa-sim library"
+ )
def test_instrument_in_context():
with Instrument("abc", "def", visa_library="@sim") as instr:
pass
|