-
Notifications
You must be signed in to change notification settings - Fork 357
Expand file tree
/
Copy pathtest_instrument_ref_parameter.py
More file actions
42 lines (28 loc) · 1.06 KB
/
test_instrument_ref_parameter.py
File metadata and controls
42 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from typing import TYPE_CHECKING
import pytest
from qcodes.instrument_drivers.mock_instruments import DummyInstrument
from qcodes.parameters import InstrumentRefParameter
if TYPE_CHECKING:
from collections.abc import Generator
class DummyHolder(DummyInstrument):
def __init__(self, name: str) -> None:
super().__init__(name)
self.test = self.add_parameter(
"test",
parameter_class=InstrumentRefParameter,
initial_value=None,
)
@pytest.fixture(name="instrument_a")
def _make_instrument_a() -> "Generator[DummyHolder, None, None]":
a = DummyHolder("dummy_holder")
yield a
a.close()
@pytest.fixture(name="instrument_d")
def _make_instrument_d() -> "Generator[DummyInstrument, None, None]":
d = DummyInstrument("dummy")
yield d
d.close()
def test_get_instr(instrument_a: DummyHolder, instrument_d: DummyInstrument) -> None:
instrument_a.test.set(instrument_d.name)
assert instrument_a.test.get() == instrument_d.name
assert instrument_a.test.get_instr() == instrument_d