From 5ba252cf8e3d7b3f79cc978b7acdb3da9c77312c Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 14 Jul 2022 20:38:20 +0200 Subject: [PATCH] remove tests that rely on parameters being an attr --- .../test_parse_parameter_attr.py | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/qcodes/tests/sphinx_extension/test_parse_parameter_attr.py b/qcodes/tests/sphinx_extension/test_parse_parameter_attr.py index e11d794eb294..1d6974acf216 100644 --- a/qcodes/tests/sphinx_extension/test_parse_parameter_attr.py +++ b/qcodes/tests/sphinx_extension/test_parse_parameter_attr.py @@ -1,7 +1,8 @@ import pytest from sphinx.util.inspect import safe_getattr -from qcodes.instrument import InstrumentBase, VisaInstrument +from qcodes.instrument import InstrumentBase +from qcodes.parameters import Parameter from qcodes.sphinx_extensions.parse_parameter_attr import ( ParameterProxy, qcodes_parameter_attr_getter, @@ -24,8 +25,13 @@ def __init__(self, *args, **kwargs): An instance attribute """ + self.my_param = Parameter( + name="my_param", instrument=self, get_cmd=None, set_cmd=None + ) + """A QCoDeS Parameter""" -class DummyNoInitClass(InstrumentBase): + +class DummyNoInitClass(DummyTestClass): myattr: str = "ClassAttribute" """ @@ -87,16 +93,13 @@ def test_extract_instance_attr(): assert repr(b) == '"InstanceAttribute"' -def test_instrument_base_get_attr(): - parameters = qcodes_parameter_attr_getter(InstrumentBase, "parameters") +def test_parameter_get_attr(): + parameters = qcodes_parameter_attr_getter(DummyTestClass, "my_param") assert isinstance(parameters, ParameterProxy) - assert repr(parameters) == "{}" - - -def test_visa_instr_get_attr(): - parameters = qcodes_parameter_attr_getter(VisaInstrument, "parameters") - assert isinstance(parameters, ParameterProxy) - assert repr(parameters) == "{}" + assert ( + repr(parameters) + == 'Parameter( name="my_param", instrument=self, get_cmd=None, set_cmd=None )' + ) def test_decorated_init_func(): @@ -113,6 +116,6 @@ def test_decorated_class(): def test_no_init(): """Test that attribute can be found from a class without an init function.""" - attr = qcodes_parameter_attr_getter(DummyNoInitClass, "parameters") + attr = qcodes_parameter_attr_getter(DummyNoInitClass, "other_attr") assert isinstance(attr, ParameterProxy) - assert repr(attr) == "{}" + assert repr(attr) == '"InstanceAttribute"'