Debian Codegraph @

tests/instruments/keithley/test_keithley2306.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2024 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24
25 from pymeasure.test import expected_protocol
26
27 from pymeasure.instruments.keithley.keithley2306 import Keithley2306
28
29
30 def test_init():
31 with expected_protocol(
32 Keithley2306,
33 [],
34 ):
35 pass # Verify the expected communication.
36
37
38 def test_nplc():
39 with expected_protocol(
40 Keithley2306,
41 [(b":SENS2:NPLC?", b"1.234")],
42 ) as instr:
43 assert instr.ch2.nplc == 1.234
44
45
46 def test_nplc_setter():
47 with expected_protocol(
48 Keithley2306,
49 [(b":SENS2:NPLC 1.234", None)],
50 ) as instr:
51 instr.ch2.nplc = 1.234
52
53
54 def test_relay():
55 with expected_protocol(
56 Keithley2306,
57 [(b":OUTP:REL2?", b"ONE")],
58 ) as instr:
59 assert instr.relay2.closed is True
60
61
62 def test_relay_setter():
63 with expected_protocol(
64 Keithley2306,
65 [(b":OUTP:REL2 ONE", None)],
66 ) as instr:
67 instr.relay2.closed = True
68
69
70 def test_step():
71 with expected_protocol(
72 Keithley2306,
73 [(b":SENS:PCUR:STEP:TLEV3?", 4)],
74 ) as instr:
75 step = instr.ch1.pulse_current_step(3)
76 assert step.trigger_level == 4