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 814f03f
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 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,14 @@ 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(DummyTestClass):

class DummyNoInitClass(InstrumentBase):
myattr: str = "ClassAttribute"
"""
A class attribute
Expand Down Expand Up @@ -83,16 +90,31 @@ 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)
<<<<<<< HEAD:tests/sphinx_extension/test_parse_parameter_attr.py

Check failure on line 96 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Expected expression

Check failure on line 96 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Expected expression
assert repr(parameters) == "{}"

Check failure on line 97 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Unexpected indentation

Check failure on line 97 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

"parameters" is not defined (reportUndefinedVariable)

Check failure on line 97 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Unexpected indentation

Check failure on line 97 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

"parameters" is not defined (reportUndefinedVariable)


def test_visa_instr_get_attr() -> None:

Check failure on line 100 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Unindent not expected

Check failure on line 100 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Function declaration "test_visa_instr_get_attr" is obscured by a declaration of the same name (reportRedeclaration)

Check failure on line 100 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Unindent not expected

Check failure on line 100 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Function declaration "test_visa_instr_get_attr" is obscured by a declaration of the same name (reportRedeclaration)
parameters = qcodes_parameter_attr_getter(VisaInstrument, "parameters")

Check failure on line 101 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

"VisaInstrument" is not defined (reportUndefinedVariable)

Check failure on line 101 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

"VisaInstrument" is not defined (reportUndefinedVariable)
assert isinstance(parameters, ParameterProxy)
assert repr(parameters) == "{}"
||||||| parent of 5ba252cf8 (remove tests that rely on parameters being an attr):qcodes/tests/sphinx_extension/test_parse_parameter_attr.py

Check failure on line 104 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Expected expression

Check failure on line 104 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Expected expression
assert repr(parameters) == "{}"

Check failure on line 105 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Unexpected indentation

Check failure on line 105 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

"parameters" is not defined (reportUndefinedVariable)

Check failure on line 105 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Unexpected indentation

Check failure on line 105 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

"parameters" is not defined (reportUndefinedVariable)


def test_visa_instr_get_attr():

Check failure on line 108 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.11, false)

Unindent not expected

Check failure on line 108 in tests/sphinx_extension/test_parse_parameter_attr.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.12, false)

Unindent not expected
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 )'
)
>>>>>>> 5ba252cf8 (remove tests that rely on parameters being an attr):qcodes/tests/sphinx_extension/test_parse_parameter_attr.py


def test_decorated_init_func() -> None:
Expand All @@ -109,6 +131,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 814f03f

Please sign in to comment.