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 Oct 3, 2024
1 parent b9f3021 commit b0ee1d9
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions 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 @@ -23,8 +24,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"
"""
A class attribute
Expand Down Expand Up @@ -83,16 +89,13 @@ def test_extract_instance_attr() -> None:
assert repr(b) == '"InstanceAttribute"'


def test_instrument_base_get_attr() -> None:
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() -> None:
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() -> None:
Expand All @@ -109,6 +112,6 @@ def test_decorated_class() -> None:

def test_no_init() -> None:
"""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 b0ee1d9

Please sign in to comment.