33import pytest
44from pytest import FixtureRequest , LogCaptureFixture
55
6- from qcodes .instrument_drivers .tektronix .Keithley_s46 import S46 , LockAcquisitionError
6+ from qcodes .instrument_drivers .Keithley .Keithley_s46 import (
7+ KeithleyS46 ,
8+ KeithleyS46LockAcquisitionError ,
9+ )
710
811
912def test_aliases_dict () -> None :
@@ -19,15 +22,17 @@ def calc_channel_nr(alias: str) -> int:
1922 offset_dict = dict (zip (["A" , "B" , "C" , "D" , "R" ], range (0 , 32 , 6 )))
2023 return offset_dict [alias [0 ]] + int (alias [1 :])
2124
22- assert all ([nr == calc_channel_nr (al ) for al , nr in S46 .channel_numbers .items ()])
25+ assert all (
26+ [nr == calc_channel_nr (al ) for al , nr in KeithleyS46 .channel_numbers .items ()]
27+ )
2328
2429
2530@pytest .fixture (scope = "function" )
2631def s46_six ():
2732 """
2833 A six channel-per-relay instrument
2934 """
30- driver = S46 (
35+ driver = KeithleyS46 (
3136 "s46_six" , address = "GPIB::2::INSTR" , pyvisa_sim_file = "Keithley_s46.yaml"
3237 )
3338
@@ -42,7 +47,7 @@ def s46_four():
4247 """
4348 A four channel-per-relay instrument
4449 """
45- driver = S46 (
50+ driver = KeithleyS46 (
4651 "s46_four" , address = "GPIB::3::INSTR" , pyvisa_sim_file = "Keithley_s46.yaml"
4752 )
4853
@@ -58,13 +63,13 @@ def test_runtime_error_on_bad_init(request: FixtureRequest) -> None:
5863 channel per relay closed, raise a runtime error. An instrument can come to
5964 this state if previously, other software was used to control the instrument
6065 """
61- request .addfinalizer (S46 .close_all )
66+ request .addfinalizer (KeithleyS46 .close_all )
6267
6368 with pytest .raises (
6469 RuntimeError ,
6570 match = "The driver is initialized from an undesirable instrument state" ,
6671 ):
67- S46 (
72+ KeithleyS46 (
6873 "s46_bad_state" ,
6974 address = "GPIB::1::INSTR" ,
7075 pyvisa_sim_file = "Keithley_s46.yaml" ,
@@ -76,7 +81,7 @@ def test_query_close_once_at_init(caplog: LogCaptureFixture) -> None:
7681 Test that, during initialisation, we query the closed channels only once
7782 """
7883 with caplog .at_level (logging .DEBUG ):
79- inst = S46 (
84+ inst = KeithleyS46 (
8085 "s46_test_query_once" ,
8186 address = "GPIB::2::INSTR" ,
8287 pyvisa_sim_file = "Keithley_s46.yaml" ,
@@ -85,14 +90,16 @@ def test_query_close_once_at_init(caplog: LogCaptureFixture) -> None:
8590 inst .close ()
8691
8792
88- def test_init_six (s46_six : S46 , caplog : LogCaptureFixture ) -> None :
93+ def test_init_six (s46_six : KeithleyS46 , caplog : LogCaptureFixture ) -> None :
8994 """
9095 Test that the six channel instrument initializes correctly.
9196 """
9297 assert len (s46_six .available_channels ) == 26
9398
9499 closed_channel_numbers = [1 , 8 , 13 ]
95- assert s46_six .closed_channels () == [S46 .aliases [i ] for i in closed_channel_numbers ]
100+ assert s46_six .closed_channels () == [
101+ KeithleyS46 .aliases [i ] for i in closed_channel_numbers
102+ ]
96103
97104 with caplog .at_level (logging .DEBUG ):
98105 s46_six .open_all_channels ()
@@ -105,15 +112,15 @@ def test_init_six(s46_six: S46, caplog: LogCaptureFixture) -> None:
105112 assert s46_six .C1 ._lock ._locked_by is None
106113
107114
108- def test_init_four (s46_four : S46 ) -> None :
115+ def test_init_four (s46_four : KeithleyS46 ) -> None :
109116 """
110117 Test that the six channel instrument initializes correctly.
111118 """
112119 assert len (s46_four .available_channels ) == 18
113120
114121 closed_channel_numbers = [1 , 8 ]
115122 assert s46_four .closed_channels () == [
116- S46 .aliases [i ] for i in closed_channel_numbers
123+ KeithleyS46 .aliases [i ] for i in closed_channel_numbers
117124 ]
118125
119126 # A four channel instrument will have channels missing
@@ -123,28 +130,30 @@ def test_init_four(s46_four: S46) -> None:
123130 assert not hasattr (s46_four , alias )
124131
125132
126- def test_channel_number_invariance (s46_four : S46 , s46_six : S46 ) -> None :
133+ def test_channel_number_invariance (s46_four : KeithleyS46 , s46_six : KeithleyS46 ) -> None :
127134 """
128135 Regardless of the channel layout (that is, number of channels per relay),
129136 channel aliases should represent the same channel. See also page 2-5 of the
130137 manual (e.g. B1 is *always* channel 7)
131138 """
132- for alias in S46 .channel_numbers .keys ():
139+ for alias in KeithleyS46 .channel_numbers .keys ():
133140 if hasattr (s46_four , alias ) and hasattr (s46_six , alias ):
134141 channel_four = getattr (s46_four , alias )
135142 channel_six = getattr (s46_six , alias )
136143 assert channel_four .channel_number == channel_six .channel_number
137144
138145
139- def test_locking_mechanism (s46_six : S46 ) -> None :
146+ def test_locking_mechanism (s46_six : KeithleyS46 ) -> None :
140147 """
141148 1) Test that the lock acquisition error is raised if we try to close
142149 more then once channel per replay
143150 2) Test that the lock is released when opening a channel that was closed
144151 """
145152 s46_six .A1 ("close" )
146153
147- with pytest .raises (LockAcquisitionError , match = "is already in use by channel" ):
154+ with pytest .raises (
155+ KeithleyS46LockAcquisitionError , match = "is already in use by channel"
156+ ):
148157 # A1 should be closed already
149158 s46_six .A2 ("close" )
150159 # release the lock
@@ -155,15 +164,17 @@ def test_locking_mechanism(s46_six: S46) -> None:
155164 # Let C1 acquire the lock
156165 s46_six .C1 ("close" )
157166 # closing C2 should raise an error
158- with pytest .raises (LockAcquisitionError , match = "is already in use by channel" ):
167+ with pytest .raises (
168+ KeithleyS46LockAcquisitionError , match = "is already in use by channel"
169+ ):
159170 s46_six .C2 ("close" )
160171
161172 # Upon opening C1 we should be able to close C2
162173 s46_six .C1 ("open" )
163174 s46_six .C2 ("close" )
164175
165176
166- def test_is_closed (s46_six : S46 ) -> None :
177+ def test_is_closed (s46_six : KeithleyS46 ) -> None :
167178 """
168179 Test the `is_closed` public method
169180 """
0 commit comments