forked from QCoDeS/Qcodes_contrib_drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sim_qdac2_init.py
33 lines (30 loc) · 1.3 KB
/
test_sim_qdac2_init.py
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
import pytest
from qcodes_contrib_drivers.drivers.QDevil import QDAC2
from qcodes.instrument.base import Instrument
from .sim_qdac2_fixtures import visalib
def test_refuse_wrong_model():
# Use simulated instruments for the tests.
wrong_instrument = 'dmm'
# -----------------------------------------------------------------------
with pytest.raises(ValueError) as error:
QDAC2.QDac2(wrong_instrument, address='GPIB::2::INSTR', visalib=visalib)
# -----------------------------------------------------------------------
assert 'Unknown model' in repr(error)
# Circumvent Instrument not handling exceptions in constructor.
# In qcodes < 0.32
try:
Instrument._all_instruments.pop(wrong_instrument)
except KeyError:
pass
def test_refuse_incompatible_firmware():
# -----------------------------------------------------------------------
with pytest.raises(ValueError) as error:
QDAC2.QDac2('qdac', address='GPIB::3::INSTR', visalib=visalib)
# -----------------------------------------------------------------------
assert 'Incompatible firmware' in repr(error)
# Circumvent Instrument not handling exceptions in constructor.
# In qcodes < 0.32
try:
Instrument._all_instruments.pop('qdac')
except KeyError:
pass