Skip to content

Commit

Permalink
remove tests that rely on parameters being an attr
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Jul 25, 2022
1 parent 4789aba commit 5ba252c
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions qcodes/tests/sphinx_extension/test_parse_parameter_attr.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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"
"""
Expand Down Expand Up @@ -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():
Expand All @@ -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"'

0 comments on commit 5ba252c

Please sign in to comment.