Skip to content

Commit

Permalink
Full coverage for Keithley 2182 & 6220
Browse files Browse the repository at this point in the history
Added and extended existing tests for these two instruments.
  • Loading branch information
trappitsch committed Nov 13, 2020
1 parent e3f2764 commit 98814ef
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
79 changes: 79 additions & 0 deletions instruments/tests/test_keithley/test_keithley2182.py
Expand Up @@ -34,6 +34,70 @@ def test_channel_mode():
) as inst:
channel = inst.channel[0]
assert channel.mode == inst.Mode.voltage_dc
with pytest.raises(NotImplementedError):
channel.mode = 42


def test_channel_trigger_mode():
"""Raise NotImplementedError when getting / setting trigger mode."""
with expected_protocol(
ik.keithley.Keithley2182,
[
],
[
]
) as inst:
channel = inst.channel[0]
with pytest.raises(NotImplementedError):
_ = channel.trigger_mode
with pytest.raises(NotImplementedError):
channel.trigger_mode = 42


def test_channel_relative():
"""Raise NotImplementedError when getting / setting relative."""
with expected_protocol(
ik.keithley.Keithley2182,
[
],
[
]
) as inst:
channel = inst.channel[0]
with pytest.raises(NotImplementedError):
_ = channel.relative
with pytest.raises(NotImplementedError):
channel.relative = 42


def test_channel_input_range():
"""Raise NotImplementedError when getting / setting input range."""
with expected_protocol(
ik.keithley.Keithley2182,
[
],
[
]
) as inst:
channel = inst.channel[0]
with pytest.raises(NotImplementedError):
_ = channel.input_range
with pytest.raises(NotImplementedError):
channel.input_range = 42


def test_channel_measure_mode_not_none():
"""Raise NotImplementedError measuring with non-None mode."""
with expected_protocol(
ik.keithley.Keithley2182,
[
],
[
]
) as inst:
channel = inst.channel[0]
with pytest.raises(NotImplementedError):
channel.measure(mode="Some Mode")


def test_channel_measure_voltage():
Expand Down Expand Up @@ -225,3 +289,18 @@ def test_relative_set_wrong_type():
[]
) as inst:
inst.relative = "derp"


def test_input_range():
"""Raise NotImplementedError when getting / setting input range."""
with expected_protocol(
ik.keithley.Keithley2182,
[
],
[
]
) as inst:
with pytest.raises(NotImplementedError):
_ = inst.input_range
with pytest.raises(NotImplementedError):
inst.input_range = 42
23 changes: 23 additions & 0 deletions instruments/tests/test_keithley/test_keithley6220.py
Expand Up @@ -7,6 +7,8 @@
# IMPORTS #####################################################################


import pytest

from instruments.units import ureg as u

import instruments as ik
Expand All @@ -20,6 +22,27 @@ def test_channel():
assert inst.channel[0] == inst


def test_voltage():
"""Raise NotImplementedError when getting / setting voltage."""
with expected_protocol(
ik.keithley.Keithley6220,
[
],
[
]
) as inst:
with pytest.raises(NotImplementedError) as err_info:
_ = inst.voltage
err_msg = err_info.value.args[0]
assert err_msg == "The Keithley 6220 does not support voltage " \
"settings."
with pytest.raises(NotImplementedError) as err_info:
inst.voltage = 42
err_msg = err_info.value.args[0]
assert err_msg == "The Keithley 6220 does not support voltage " \
"settings."


def test_current():
with expected_protocol(
ik.keithley.Keithley6220,
Expand Down

0 comments on commit 98814ef

Please sign in to comment.