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
