Debian Codegraph @

tests/instruments/keithley/test_keithleyDMM6500.py

raw
1 import pytest
2
3 from pymeasure.test import expected_protocol
4 from pymeasure.instruments.keithley import KeithleyDMM6500
5
6
7 def test_init():
8 with expected_protocol(
9 KeithleyDMM6500,
10 [(b'*LANG SCPI', None)],
11 ):
12 pass # Verify the expected communication.
13
14
15 def test_aperture_setter():
16 with expected_protocol(
17 KeithleyDMM6500,
18 [(b'*LANG SCPI', None),
19 (b':SENS:FUNC?', b'CURR:DC\n'),
20 (b'CURR:DC:APER 0.0015', None)],
21 ) as inst:
22 inst.aperture = 0.0015
23
24
25 def test_aperture_getter():
26 with expected_protocol(
27 KeithleyDMM6500,
28 [(b'*LANG SCPI', None),
29 (b':SENS:FUNC?', b'CURR:DC\n'),
30 (b'CURR:DC:APER?', b'0.0015\n')],
31 ) as inst:
32 assert inst.aperture == 0.0015
33
34
35 def test_autorange_enabled_setter():
36 with expected_protocol(
37 KeithleyDMM6500,
38 [(b'*LANG SCPI', None),
39 (b':SENS:FUNC?', b'CURR:DC\n'),
40 (b'CURR:DC:RANG:AUTO 1', None)],
41 ) as inst:
42 inst.autorange_enabled = True
43
44
45 @pytest.mark.parametrize("comm_pairs, value", (
46 ([(b'*LANG SCPI', None),
47 (b':SENS:FUNC?', b'CURR:DC\n'),
48 (b'CURR:DC:RANG:AUTO?', b'0\n')],
49 False),
50 ([(b'*LANG SCPI', None),
51 (b':SENS:FUNC?', b'CURR:DC\n'),
52 (b'CURR:DC:RANG:AUTO?', b'1\n')],
53 True),
54 ))
55 def test_autorange_enabled_getter(comm_pairs, value):
56 with expected_protocol(
57 KeithleyDMM6500,
58 comm_pairs,
59 ) as inst:
60 assert inst.autorange_enabled == value
61
62
63 def test_autozero_enabled_setter():
64 with expected_protocol(
65 KeithleyDMM6500,
66 [(b'*LANG SCPI', None),
67 (b':SENS:FUNC?', b'CURR:DC\n'),
68 (b'CURR:DC:AZER 0', None)],
69 ) as inst:
70 inst.autozero_enabled = False
71
72
73 @pytest.mark.parametrize("comm_pairs, value", (
74 ([(b'*LANG SCPI', None),
75 (b':SENS:FUNC?', b'CURR:DC\n'),
76 (b'CURR:DC:AZER?', b'1\n')],
77 True),
78 ([(b'*LANG SCPI', None),
79 (b':SENS:FUNC?', b'CURR:DC\n'),
80 (b'CURR:DC:AZER?', b'0\n')],
81 False),
82 ))
83 def test_autozero_enabled_getter(comm_pairs, value):
84 with expected_protocol(
85 KeithleyDMM6500,
86 comm_pairs,
87 ) as inst:
88 assert inst.autozero_enabled == value
89
90
91 def test_command_set_getter():
92 with expected_protocol(
93 KeithleyDMM6500,
94 [(b'*LANG SCPI', None),
95 (b'*LANG?', b'SCPI\n')],
96 ) as inst:
97 assert inst.command_set == 'SCPI'
98
99
100 @pytest.mark.parametrize("comm_pairs, value", (
101 ([(b'*LANG SCPI', None),
102 (b':READ?', b'-4.999995E-01\n')],
103 -0.4999995),
104 ([(b'*LANG SCPI', None),
105 (b':READ?', b'3.414127E-04\n')],
106 0.0003414127),
107 ))
108 def test_current_getter(comm_pairs, value):
109 with expected_protocol(
110 KeithleyDMM6500,
111 comm_pairs,
112 ) as inst:
113 assert inst.current == value
114
115
116 def test_current_ac_bandwidth_getter():
117 with expected_protocol(
118 KeithleyDMM6500,
119 [(b'*LANG SCPI', None),
120 (b':SENS:CURR:AC:DET:BAND?', b'30\n')],
121 ) as inst:
122 assert inst.current_ac_bandwidth == 30.0
123
124
125 def test_current_ac_digits_getter():
126 with expected_protocol(
127 KeithleyDMM6500,
128 [(b'*LANG SCPI', None),
129 (b':DISP:CURR:AC:DIG?', b'6\n')],
130 ) as inst:
131 assert inst.current_ac_digits == 6
132
133
134 def test_current_ac_range_getter():
135 with expected_protocol(
136 KeithleyDMM6500,
137 [(b'*LANG SCPI', None),
138 (b':SENS:CURR:AC:RANG?', b'0.01\n')],
139 ) as inst:
140 assert inst.current_ac_range == 0.01
141
142
143 def test_current_ac_relative_getter():
144 with expected_protocol(
145 KeithleyDMM6500,
146 [(b'*LANG SCPI', None),
147 (b':SENS:CURR:AC:REL?', b'0\n')],
148 ) as inst:
149 assert inst.current_ac_relative == 0.0
150
151
152 def test_current_ac_relative_enabled_getter():
153 with expected_protocol(
154 KeithleyDMM6500,
155 [(b'*LANG SCPI', None),
156 (b':SENS:CURR:AC:REL:STAT?', b'0\n')],
157 ) as inst:
158 assert inst.current_ac_relative_enabled is False
159
160
161 def test_current_digits_getter():
162 with expected_protocol(
163 KeithleyDMM6500,
164 [(b'*LANG SCPI', None),
165 (b':DISP:CURR:DIG?', b'3\n')],
166 ) as inst:
167 assert inst.current_digits == 3
168
169
170 def test_current_nplc_getter():
171 with expected_protocol(
172 KeithleyDMM6500,
173 [(b'*LANG SCPI', None),
174 (b':SENS:CURR:NPLC?', b'2\n')],
175 ) as inst:
176 assert inst.current_nplc == 2.0
177
178
179 def test_current_range_getter():
180 with expected_protocol(
181 KeithleyDMM6500,
182 [(b'*LANG SCPI', None),
183 (b':SENS:CURR:RANG?', b'0.01\n')],
184 ) as inst:
185 assert inst.current_range == 0.01
186
187
188 def test_current_relative_getter():
189 with expected_protocol(
190 KeithleyDMM6500,
191 [(b'*LANG SCPI', None),
192 (b':SENS:CURR:REL?', b'0.5\n')],
193 ) as inst:
194 assert inst.current_relative == 0.5
195
196
197 def test_current_relative_enabled_getter():
198 with expected_protocol(
199 KeithleyDMM6500,
200 [(b'*LANG SCPI', None),
201 (b':SENS:CURR:REL:STAT?', b'1\n')],
202 ) as inst:
203 assert inst.current_relative_enabled is True
204
205
206 def test_detector_bandwidth_setter():
207 with expected_protocol(
208 KeithleyDMM6500,
209 [(b'*LANG SCPI', None),
210 (b':SENS:FUNC?', b'CURR:AC\n'),
211 (b'CURR:AC:DET:BAND 30', None)],
212 ) as inst:
213 inst.detector_bandwidth = 30
214
215
216 def test_detector_bandwidth_getter():
217 with expected_protocol(
218 KeithleyDMM6500,
219 [(b'*LANG SCPI', None),
220 (b':SENS:FUNC?', b'CURR:AC\n'),
221 (b'CURR:AC:DET:BAND?', b'30\n')],
222 ) as inst:
223 assert inst.detector_bandwidth == 30.0
224
225
226 def test_digits_setter():
227 with expected_protocol(
228 KeithleyDMM6500,
229 [(b'*LANG SCPI', None),
230 (b':SENS:FUNC?', b'CURR:DC\n'),
231 (b':DISP:CURR:DC:DIG 3', None)],
232 ) as inst:
233 inst.digits = 3
234
235
236 def test_digits_getter():
237 with expected_protocol(
238 KeithleyDMM6500,
239 [(b'*LANG SCPI', None),
240 (b':SENS:FUNC?', b'CURR:DC\n'),
241 (b':DISP:CURR:DC:DIG?', b'3\n')],
242 ) as inst:
243 assert inst.digits == 3
244
245
246 def test_frequency_getter():
247 with expected_protocol(
248 KeithleyDMM6500,
249 [(b'*LANG SCPI', None),
250 (b':READ?', b'0.000000E+00\n')],
251 ) as inst:
252 assert inst.frequency == 0.0
253
254
255 def test_frequency_aperature_getter():
256 with expected_protocol(
257 KeithleyDMM6500,
258 [(b'*LANG SCPI', None),
259 (b':SENS:FREQ:APER?', b'0.2\n')],
260 ) as inst:
261 assert inst.frequency_aperature == 0.2
262
263
264 def test_frequency_digits_getter():
265 with expected_protocol(
266 KeithleyDMM6500,
267 [(b'*LANG SCPI', None),
268 (b':DISP:FREQ:DIG?', b'6\n')],
269 ) as inst:
270 assert inst.frequency_digits == 6
271
272
273 def test_frequency_relative_getter():
274 with expected_protocol(
275 KeithleyDMM6500,
276 [(b'*LANG SCPI', None),
277 (b':SENS:FREQ:REL?', b'0\n')],
278 ) as inst:
279 assert inst.frequency_relative == 0.0
280
281
282 def test_frequency_relative_enabled_getter():
283 with expected_protocol(
284 KeithleyDMM6500,
285 [(b'*LANG SCPI', None),
286 (b':SENS:FREQ:REL:STAT?', b'0\n')],
287 ) as inst:
288 assert inst.frequency_relative_enabled is False
289
290
291 def test_frequency_threshold_getter():
292 with expected_protocol(
293 KeithleyDMM6500,
294 [(b'*LANG SCPI', None),
295 (b':SENS:FREQ:THR:RANG?', b'10\n')],
296 ) as inst:
297 assert inst.frequency_threshold == 10.0
298
299
300 def test_frequency_threshold_auto_enabled_getter():
301 with expected_protocol(
302 KeithleyDMM6500,
303 [(b'*LANG SCPI', None),
304 (b':SENS:FREQ:THR:RANG:AUTO?', b'1\n')],
305 ) as inst:
306 assert inst.frequency_threshold_auto_enabled is True
307
308
309 def test_id_getter():
310 with expected_protocol(
311 KeithleyDMM6500,
312 [(b'*LANG SCPI', None),
313 (b'*IDN?', b'KEITHLEY INSTRUMENTS,MODEL DMM6500,04592448,1.7.12b\n')],
314 ) as inst:
315 assert inst.id == 'KEITHLEY INSTRUMENTS,MODEL DMM6500,04592448,1.7.12b'
316
317
318 def test_line_frequency_getter():
319 with expected_protocol(
320 KeithleyDMM6500,
321 [(b'*LANG SCPI', None),
322 (b':SYST:LFR?', b'60\n')],
323 ) as inst:
324 assert inst.line_frequency == 60.0
325
326
327 @pytest.mark.parametrize("comm_pairs, value", (
328 ([(b'*LANG SCPI', None),
329 (b':SENS:FUNC "CURR:DC"', None)],
330 'current'),
331 ([(b'*LANG SCPI', None),
332 (b':SENS:FUNC "CURR:AC"', None)],
333 'current ac'),
334 ([(b'*LANG SCPI', None),
335 (b':SENS:FUNC "VOLT:DC"', None)],
336 'voltage'),
337 ))
338 def test_mode_setter(comm_pairs, value):
339 with expected_protocol(
340 KeithleyDMM6500,
341 comm_pairs,
342 ) as inst:
343 inst.mode = value
344
345
346 @pytest.mark.parametrize("comm_pairs, value", (
347 ([(b'*LANG SCPI', None),
348 (b':SENS:FUNC?', b'CURR:DC\n')],
349 'current'),
350 ([(b'*LANG SCPI', None),
351 (b':SENS:FUNC?', b'CURR:AC\n')],
352 'current ac'),
353 ([(b'*LANG SCPI', None),
354 (b':SENS:FUNC?', b'VOLT:AC\n')],
355 'voltage ac'),
356 ))
357 def test_mode_getter(comm_pairs, value):
358 with expected_protocol(
359 KeithleyDMM6500,
360 comm_pairs,
361 ) as inst:
362 assert inst.mode == value
363
364
365 def test_nplc_setter():
366 with expected_protocol(
367 KeithleyDMM6500,
368 [(b'*LANG SCPI', None),
369 (b':SENS:FUNC?', b'CURR:DC\n'),
370 (b'CURR:DC:NPLC 2', None)],
371 ) as inst:
372 inst.nplc = 2
373
374
375 def test_nplc_getter():
376 with expected_protocol(
377 KeithleyDMM6500,
378 [(b'*LANG SCPI', None),
379 (b':SENS:FUNC?', b'CURR:DC\n'),
380 (b'CURR:DC:NPLC?', b'2\n')],
381 ) as inst:
382 assert inst.nplc == 2.0
383
384
385 def test_period_getter():
386 with expected_protocol(
387 KeithleyDMM6500,
388 [(b'*LANG SCPI', None),
389 (b':READ?', b'0.000000E+00\n')],
390 ) as inst:
391 assert inst.period == 0.0
392
393
394 def test_period_aperature_getter():
395 with expected_protocol(
396 KeithleyDMM6500,
397 [(b'*LANG SCPI', None),
398 (b':SENS:PER:APER?', b'0.2\n')],
399 ) as inst:
400 assert inst.period_aperature == 0.2
401
402
403 def test_period_digits_getter():
404 with expected_protocol(
405 KeithleyDMM6500,
406 [(b'*LANG SCPI', None),
407 (b':DISP:PER:DIG?', b'6\n')],
408 ) as inst:
409 assert inst.period_digits == 6
410
411
412 def test_period_relative_getter():
413 with expected_protocol(
414 KeithleyDMM6500,
415 [(b'*LANG SCPI', None),
416 (b':SENS:PER:REL?', b'0\n')],
417 ) as inst:
418 assert inst.period_relative == 0.0
419
420
421 def test_period_relative_enabled_getter():
422 with expected_protocol(
423 KeithleyDMM6500,
424 [(b'*LANG SCPI', None),
425 (b':SENS:PER:REL:STAT?', b'0\n')],
426 ) as inst:
427 assert inst.period_relative_enabled is False
428
429
430 def test_period_threshold_getter():
431 with expected_protocol(
432 KeithleyDMM6500,
433 [(b'*LANG SCPI', None),
434 (b':SENS:PER:THR:RANG?', b'0.1\n')],
435 ) as inst:
436 assert inst.period_threshold == 0.1
437
438
439 def test_period_threshold_auto_enabled_getter():
440 with expected_protocol(
441 KeithleyDMM6500,
442 [(b'*LANG SCPI', None),
443 (b':SENS:PER:THR:RANG:AUTO?', b'1\n')],
444 ) as inst:
445 assert inst.period_threshold_auto_enabled is True
446
447
448 def test_range_setter():
449 with expected_protocol(
450 KeithleyDMM6500,
451 [(b'*LANG SCPI', None),
452 (b':SENS:FUNC?', b'CURR:DC\n'),
453 (b'CURR:DC:RANG:AUTO 0;UPP 1.0', None)],
454 ) as inst:
455 inst.range = 1.0
456
457
458 def test_range_getter():
459 with expected_protocol(
460 KeithleyDMM6500,
461 [(b'*LANG SCPI', None),
462 (b':SENS:FUNC?', b'CURR:DC\n'),
463 (b'CURR:DC:RANG?', b'1\n')],
464 ) as inst:
465 assert inst.range == 1.0
466
467
468 def test_relative_setter():
469 with expected_protocol(
470 KeithleyDMM6500,
471 [(b'*LANG SCPI', None),
472 (b':SENS:FUNC?', b'CURR:DC\n'),
473 (b'CURR:DC:REL 0.5', None)],
474 ) as inst:
475 inst.relative = 0.5
476
477
478 def test_relative_getter():
479 with expected_protocol(
480 KeithleyDMM6500,
481 [(b'*LANG SCPI', None),
482 (b':SENS:FUNC?', b'CURR:DC\n'),
483 (b'CURR:DC:REL?', b'0.5\n')],
484 ) as inst:
485 assert inst.relative == 0.5
486
487
488 def test_relative_enabled_setter():
489 with expected_protocol(
490 KeithleyDMM6500,
491 [(b'*LANG SCPI', None),
492 (b':SENS:FUNC?', b'CURR:DC\n'),
493 (b'CURR:DC:REL:STAT 1', None)],
494 ) as inst:
495 inst.relative_enabled = True
496
497
498 @pytest.mark.parametrize("comm_pairs, value", (
499 ([(b'*LANG SCPI', None),
500 (b':SENS:FUNC?', b'CURR:DC\n'),
501 (b'CURR:DC:REL:STAT?', b'0\n')],
502 False),
503 ([(b'*LANG SCPI', None),
504 (b':SENS:FUNC?', b'CURR:DC\n'),
505 (b'CURR:DC:REL:STAT?', b'1\n')],
506 True),
507 ))
508 def test_relative_enabled_getter(comm_pairs, value):
509 with expected_protocol(
510 KeithleyDMM6500,
511 comm_pairs,
512 ) as inst:
513 assert inst.relative_enabled == value
514
515
516 @pytest.mark.parametrize("comm_pairs, value", (
517 ([(b'*LANG SCPI', None),
518 (b':READ?', b'9.900000E+37\n')],
519 9.9e+37),
520 ([(b'*LANG SCPI', None),
521 (b':READ?', b'9.900000E+37\n')],
522 9.9e+37),
523 ))
524 def test_resistance_getter(comm_pairs, value):
525 with expected_protocol(
526 KeithleyDMM6500,
527 comm_pairs,
528 ) as inst:
529 assert inst.resistance == value
530
531
532 def test_resistance_4W_digits_getter():
533 with expected_protocol(
534 KeithleyDMM6500,
535 [(b'*LANG SCPI', None),
536 (b':DISP:FRES:DIG?', b'6\n')],
537 ) as inst:
538 assert inst.resistance_4W_digits == 6
539
540
541 def test_resistance_4W_nplc_getter():
542 with expected_protocol(
543 KeithleyDMM6500,
544 [(b'*LANG SCPI', None),
545 (b':SENS:FRES:NPLC?', b'1\n')],
546 ) as inst:
547 assert inst.resistance_4W_nplc == 1.0
548
549
550 def test_resistance_4W_range_getter():
551 with expected_protocol(
552 KeithleyDMM6500,
553 [(b'*LANG SCPI', None),
554 (b':SENS:FRES:RANG?', b'1E+07\n')],
555 ) as inst:
556 assert inst.resistance_4W_range == 10000000.0
557
558
559 def test_resistance_4W_relative_getter():
560 with expected_protocol(
561 KeithleyDMM6500,
562 [(b'*LANG SCPI', None),
563 (b':SENS:FRES:REL?', b'0\n')],
564 ) as inst:
565 assert inst.resistance_4W_relative == 0.0
566
567
568 def test_resistance_4W_relative_enabled_getter():
569 with expected_protocol(
570 KeithleyDMM6500,
571 [(b'*LANG SCPI', None),
572 (b':SENS:FRES:REL:STAT?', b'0\n')],
573 ) as inst:
574 assert inst.resistance_4W_relative_enabled is False
575
576
577 def test_resistance_digits_getter():
578 with expected_protocol(
579 KeithleyDMM6500,
580 [(b'*LANG SCPI', None),
581 (b':DISP:RES:DIG?', b'6\n')],
582 ) as inst:
583 assert inst.resistance_digits == 6
584
585
586 def test_resistance_nplc_getter():
587 with expected_protocol(
588 KeithleyDMM6500,
589 [(b'*LANG SCPI', None),
590 (b':SENS:RES:NPLC?', b'1\n')],
591 ) as inst:
592 assert inst.resistance_nplc == 1.0
593
594
595 def test_resistance_range_getter():
596 with expected_protocol(
597 KeithleyDMM6500,
598 [(b'*LANG SCPI', None),
599 (b':SENS:RES:RANG?', b'1E+07\n')],
600 ) as inst:
601 assert inst.resistance_range == 10000000.0
602
603
604 def test_resistance_relative_getter():
605 with expected_protocol(
606 KeithleyDMM6500,
607 [(b'*LANG SCPI', None),
608 (b':SENS:RES:REL?', b'0\n')],
609 ) as inst:
610 assert inst.resistance_relative == 0.0
611
612
613 def test_resistance_relative_enabled_getter():
614 with expected_protocol(
615 KeithleyDMM6500,
616 [(b'*LANG SCPI', None),
617 (b':SENS:RES:REL:STAT?', b'0\n')],
618 ) as inst:
619 assert inst.resistance_relative_enabled is False
620
621
622 def test_system_time_getter():
623 with expected_protocol(
624 KeithleyDMM6500,
625 [(b'*LANG SCPI', None),
626 (b':SYST:TIME? 1', b'Thu Sep 21 09:06:41 2023\n')],
627 ) as inst:
628 assert inst.system_time == 'Thu Sep 21 09:06:41 2023'
629
630
631 def test_terminals_used_getter():
632 with expected_protocol(
633 KeithleyDMM6500,
634 [(b'*LANG SCPI', None),
635 (b'ROUT:TERM?', b'REAR\n')],
636 ) as inst:
637 assert inst.terminals_used == 'REAR'
638
639
640 @pytest.mark.parametrize("comm_pairs, value", (
641 ([(b'*LANG SCPI', None),
642 (b':READ?', b'1.200272E-03\n')],
643 0.001200272),
644 ([(b'*LANG SCPI', None),
645 (b':READ?', b'5.943143E-04\n')],
646 0.0005943143),
647 ))
648 def test_voltage_getter(comm_pairs, value):
649 with expected_protocol(
650 KeithleyDMM6500,
651 comm_pairs,
652 ) as inst:
653 assert inst.voltage == value
654
655
656 def test_voltage_ac_bandwidth_getter():
657 with expected_protocol(
658 KeithleyDMM6500,
659 [(b'*LANG SCPI', None),
660 (b':SENS:VOLT:AC:DET:BAND?', b'3\n')],
661 ) as inst:
662 assert inst.voltage_ac_bandwidth == 3.0
663
664
665 def test_voltage_ac_digits_getter():
666 with expected_protocol(
667 KeithleyDMM6500,
668 [(b'*LANG SCPI', None),
669 (b':DISP:VOLT:AC:DIG?', b'6\n')],
670 ) as inst:
671 assert inst.voltage_ac_digits == 6
672
673
674 def test_voltage_ac_range_getter():
675 with expected_protocol(
676 KeithleyDMM6500,
677 [(b'*LANG SCPI', None),
678 (b':SENS:VOLT:AC:RANG?', b'1\n')],
679 ) as inst:
680 assert inst.voltage_ac_range == 1.0
681
682
683 def test_voltage_ac_relative_getter():
684 with expected_protocol(
685 KeithleyDMM6500,
686 [(b'*LANG SCPI', None),
687 (b':SENS:VOLT:AC:REL?', b'0\n')],
688 ) as inst:
689 assert inst.voltage_ac_relative == 0.0
690
691
692 def test_voltage_digits_getter():
693 with expected_protocol(
694 KeithleyDMM6500,
695 [(b'*LANG SCPI', None),
696 (b':DISP:VOLT:DIG?', b'6\n')],
697 ) as inst:
698 assert inst.voltage_digits == 6
699
700
701 def test_voltage_nplc_getter():
702 with expected_protocol(
703 KeithleyDMM6500,
704 [(b'*LANG SCPI', None),
705 (b':SENS:VOLT:NPLC?', b'1\n')],
706 ) as inst:
707 assert inst.voltage_nplc == 1.0
708
709
710 def test_voltage_range_getter():
711 with expected_protocol(
712 KeithleyDMM6500,
713 [(b'*LANG SCPI', None),
714 (b':SENS:VOLT:RANG?', b'1\n')],
715 ) as inst:
716 assert inst.voltage_range == 1.0
717
718
719 def test_voltage_relative_getter():
720 with expected_protocol(
721 KeithleyDMM6500,
722 [(b'*LANG SCPI', None),
723 (b':SENS:VOLT:REL?', b'0\n')],
724 ) as inst:
725 assert inst.voltage_relative == 0.0
726
727
728 @pytest.mark.parametrize("comm_pairs, value", (
729 ([(b'*LANG SCPI', None),
730 (b':SENS:VOLT:REL:STAT?', b'0\n')],
731 False),
732 ([(b'*LANG SCPI', None),
733 (b':SENS:VOLT:REL:STAT?', b'0\n')],
734 False),
735 ))
736 def test_voltage_relative_enabled_getter(comm_pairs, value):
737 with expected_protocol(
738 KeithleyDMM6500,
739 comm_pairs,
740 ) as inst:
741 assert inst.voltage_relative_enabled == value
742
743
744 def test_check_errors():
745 with expected_protocol(
746 KeithleyDMM6500,
747 [(b'*LANG SCPI', None),
748 (b'SYST:ERR?', b'0,"No error;0;0 0"\n')],
749 ) as inst:
750 assert inst.check_errors() == []
751
752
753 def test_clear():
754 with expected_protocol(
755 KeithleyDMM6500,
756 [(b'*LANG SCPI', None),
757 (b'*CLS', None)],
758 ) as inst:
759 assert inst.clear() is None
760
761
762 def test_displayed_text():
763 with expected_protocol(
764 KeithleyDMM6500,
765 [(b'*LANG SCPI', None),
766 (b':DISP:CLE', None),
767 (b':DISP:SCR SWIPE_USER', None),
768 (b':DISP:USER1:TEXT "Hello"', None),
769 (b':DISP:USER2:TEXT "DMM6500"', None)],
770 ) as inst:
771 assert inst.displayed_text(*('Hello', 'DMM6500'), ) is None
772
773
774 @pytest.mark.parametrize("comm_pairs, args, kwargs, value", (
775 ([(b'*LANG SCPI', None),
776 (b':SENS:FUNC "CURR:DC"', None),
777 (b':SENS:CURR:RANG:AUTO 0;:SENS:CURR:RANG 0.01', None)],
778 (), {}, None),
779 ([(b'*LANG SCPI', None),
780 (b':SENS:FUNC "CURR:AC"', None),
781 (b':SENS:CURR:AC:RANG:AUTO 0;:SENS:CURR:AC:RANG 0.01', None)],
782 (), {'ac': True}, None),
783 ))
784 def test_measure_current(comm_pairs, args, kwargs, value):
785 with expected_protocol(
786 KeithleyDMM6500,
787 comm_pairs,
788 ) as inst:
789 assert inst.measure_current(*args, **kwargs) == value
790
791
792 def test_measure_frequency():
793 with expected_protocol(
794 KeithleyDMM6500,
795 [(b'*LANG SCPI', None),
796 (b':SENS:FUNC "FREQ:VOLT"', None)],
797 ) as inst:
798 assert inst.measure_frequency() is None
799
800
801 def test_measure_period():
802 with expected_protocol(
803 KeithleyDMM6500,
804 [(b'*LANG SCPI', None),
805 (b':SENS:FUNC "PER:VOLT"', None)],
806 ) as inst:
807 assert inst.measure_period() is None
808
809
810 @pytest.mark.parametrize("comm_pairs, args, kwargs, value", (
811 ([(b'*LANG SCPI', None),
812 (b':SENS:FUNC "RES"', None),
813 (b':SENS:RES:RANG:AUTO 0;:SENS:RES:RANG 1e+07', None)],
814 (), {}, None),
815 ([(b'*LANG SCPI', None),
816 (b':SENS:FUNC "FRES"', None),
817 (b':SENS:FRES:RANG:AUTO 0;:SENS:FRES:RANG 1e+07', None)],
818 (), {'wires': 4}, None),
819 ))
820 def test_measure_resistance(comm_pairs, args, kwargs, value):
821 with expected_protocol(
822 KeithleyDMM6500,
823 comm_pairs,
824 ) as inst:
825 assert inst.measure_resistance(*args, **kwargs) == value
826
827
828 @pytest.mark.parametrize("comm_pairs, args, kwargs, value", (
829 ([(b'*LANG SCPI', None),
830 (b':SENS:FUNC "VOLT:DC"', None),
831 (b':SENS:VOLT:RANG:AUTO 0;:SENS:VOLT:RANG 1', None)],
832 (), {}, None),
833 ([(b'*LANG SCPI', None),
834 (b':SENS:FUNC "VOLT:AC"', None),
835 (b':SENS:VOLT:RANG:AUTO 0;:SENS:VOLT:AC:RANG 1', None)],
836 (), {'ac': True}, None),
837 ))
838 def test_measure_voltage(comm_pairs, args, kwargs, value):
839 with expected_protocol(
840 KeithleyDMM6500,
841 comm_pairs,
842 ) as inst:
843 assert inst.measure_voltage(*args, **kwargs) == value
844
845
846 def test_reset():
847 with expected_protocol(
848 KeithleyDMM6500,
849 [(b'*LANG SCPI', None),
850 (b'*RST', None)],
851 ) as inst:
852 assert inst.reset() is None
853
854
855 def test_trigger_single_autozero():
856 with expected_protocol(
857 KeithleyDMM6500,
858 [(b'*LANG SCPI', None),
859 (b'AZER:ONCE', None)],
860 ) as inst:
861 assert inst.trigger_single_autozero() is None