Repository: pymeasure/pymeasure

Issue:
Many instruments miss name argument
Many instruments miss a name argument and pass their name directly to the super constructor.


Discussion:

Resolving patch:
diff --git a/pymeasure/instruments/__init__.py b/pymeasure/instruments/__init__.py
--- a/pymeasure/instruments/__init__.py
+++ b/pymeasure/instruments/__init__.py
@@ -38,8 +38,10 @@
 from . import andeenhagerling
 from . import anritsu
 from . import attocube
+from . import bkprecision
 from . import danfysik
 from . import deltaelektronika
+from . import edwards
 from . import eurotest
 from . import fluke
 from . import fwbell
@@ -53,6 +55,7 @@
 from . import ni
 from . import oxfordinstruments
 from . import parker
+from . import pendulum
 from . import razorbill
 from . import rohdeschwarz
 from . import siglenttechnologies
@@ -60,6 +63,7 @@
 from . import srs
 from . import tektronix
 from . import temptronic
+from . import texio
 from . import thermotron
 from . import thorlabs
 from . import toptica
diff --git a/pymeasure/instruments/temptronic/temptronic_base.py b/pymeasure/instruments/temptronic/temptronic_base.py
--- a/pymeasure/instruments/temptronic/temptronic_base.py
+++ b/pymeasure/instruments/temptronic/temptronic_base.py
@@ -556,8 +556,8 @@ class ATSBase(Instrument):
         dynamic=True
     )
 
-    def __init__(self, adapter, **kwargs):
-        super().__init__(adapter, query_delay=0.05, **kwargs)
+    def __init__(self, adapter, name="ATSBase", **kwargs):
+        super().__init__(adapter, name=name, query_delay=0.05, **kwargs)
 
     def reset(self):
         """Reset (force) the System to the Operator screen.


Test patch:
diff --git a/tests/instruments/test_all_instruments.py b/tests/instruments/test_all_instruments.py
--- a/tests/instruments/test_all_instruments.py
+++ b/tests/instruments/test_all_instruments.py
@@ -50,18 +50,113 @@
 
 # Instruments unable to accept an Adapter instance.
 proper_adapters = ["IBeamSmart", "ANC300Controller"]
-# Instruments with communication in their __init__ which consequently fails.
-init = ["ThorlabsPM100USB", "Keithley2700", "TC038", "Agilent34450A",
-        "AWG401x_AWG", "AWG401x_AFG", "VARX", "HP8116A"]
-# Instruments which require more input arguments
-init.extend(["Instrument", "ATSBase"])
+# Instruments with communication in their __init__, which consequently fails.
+need_init_communication = [
+    "ThorlabsPM100USB",
+    "Keithley2700",
+    "TC038",
+    "Agilent34450A",
+    "AWG401x_AWG",
+    "AWG401x_AFG",
+    "VARX",
+    "HP8116A",
+]
 
 
 @pytest.mark.parametrize("cls", devices)
-def test_args(cls):
+def test_adapter_arg(cls):
     "Test that every instrument has adapter as their input argument"
     if cls.__name__ in proper_adapters:
         pytest.skip(f"{cls.__name__} does not accept an Adapter instance.")
-    elif cls.__name__ in init:
+    elif cls.__name__ in need_init_communication:
         pytest.skip(f"{cls.__name__} requires communication in init.")
+    elif cls.__name__ == "Instrument":
+        pytest.skip("`Instrument` requires a `name` parameter.")
     cls(adapter=MagicMock())
+
+
+# Instruments which do not yet accept "name" argument
+nameless_instruments = [
+    "AdvantestR3767CG",
+    "Agilent33220A",
+    "Agilent33500",
+    "Agilent33521A",
+    "Agilent34410A",
+    "Agilent4156",
+    "Agilent8257D",
+    "Agilent8722ES",
+    "AgilentB1500",
+    "AgilentE4408B",
+    "AgilentE4980",
+    "Ametek7270",
+    "AMI430",
+    "DPSeriesMotorController",
+    "APSIN12G",
+    "AnritsuMG3692C",
+    "AnritsuMS9740A",
+    "BKPrecision9130B",
+    "Danfysik8500",
+    "SM7045D",  # deltaelektronika
+    "Nxds",  # edwards
+    "EurotestHPP120256",
+    "Fluke7341",
+    "FWBell5080",
+    "ND287",
+    "HP33120A",
+    "HP3437A",
+    "HP34401A",
+    "HP3478A",
+    "HP6632A",
+    "HP6633A",
+    "HP6634A",
+    "HP8657B",
+    "Keithley2000",
+    "Keithley2306",
+    "Keithley2400",
+    "Keithley2450",
+    "Keithley2600",
+    "Keithley2750",
+    "Keithley6221",
+    "Keithley6517B",
+    "KeysightDSOX1102G",
+    "KeysightN5767A",
+    "KeysightN7776C",
+    "LakeShore331",
+    "LakeShore421",
+    "LakeShore425",
+    "ESP300",
+    "ParkerGV6",
+    "CNT91",  # pendulum
+    "razorbillRP100",
+    "FSL",
+    "SFM",
+    "SPD1168X",  # siglenttechnologies
+    "SPD1305X",  # siglenttechnologies
+    "DSP7265",
+    "SG380",
+    "SR510",
+    "SR570",
+    "SR830",
+    "SR860",
+    "AFG3152C",
+    "TDS2000",  # tectronix
+    "ATS525",  # temptronic
+    "ATS545",  # temptronic
+    "ECO560",  # temptronic
+    "TexioPSW360L30",
+    "Thermotron3800",
+    "ThorlabsPro8000",
+    "Yokogawa7651",
+    "YokogawaGS200",
+]
+
+
+@pytest.mark.parametrize("cls", devices)
+def test_name_argument(cls):
+    "Test that every instrument accepts a name argument"
+    if cls.__name__ in (*proper_adapters, *need_init_communication):
+        pytest.skip(f"{cls.__name__} cannot be tested without communication.")
+    elif cls.__name__ in nameless_instruments:
+        pytest.skip(f"{cls.__name__} does not accept a name argument yet.")
+    inst = cls(adapter=MagicMock(), name="Name_Test")
+    assert inst.name == "Name_Test"