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