diff --git a/bindings/python/conftest.py b/bindings/python/conftest.py index d3d435e98..89ba590d9 100644 --- a/bindings/python/conftest.py +++ b/bindings/python/conftest.py @@ -1,13 +1,20 @@ """Tests of the Python bindings for Hamlib """ import pytest +import sys def pytest_addoption(parser): # using long options only because short options conflict with pytest's - parser.addoption('--model', type=int, default=1, - metavar='ID', help='select radio model number') - parser.addoption('--rig-file', default=None, - metavar='DEVICE', help='set device of the radio to operate on') + if sys.argv[1].endswith("rig.py"): + parser.addoption('--model', type=int, default=1, + metavar='ID', help='select radio model number') + parser.addoption('--rig-file', default=None, + metavar='DEVICE', help='set device of the radio to operate on') + elif sys.argv[1].endswith("rot.py"): + parser.addoption('--model', type=int, default=1, + metavar='ID', help='select rotator model number') + parser.addoption('--rot-file', default=None, + metavar='DEVICE', help='set device of the rotator to operate on') parser.addoption('--serial-speed', type=int, default=0, metavar='BAUD', help='set serial speed of the serial port') parser.addoption('--hamlib-verbose', action='count', default=0, diff --git a/bindings/python/test_rot.py b/bindings/python/test_rot.py old mode 100644 new mode 100755 index f51ea46ce..c87835534 --- a/bindings/python/test_rot.py +++ b/bindings/python/test_rot.py @@ -11,8 +11,6 @@ import Hamlib Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE) -ROT_MODEL = Hamlib.ROT_MODEL_DUMMY - class TestClass: """Container class for tests""" @@ -23,9 +21,9 @@ class TestClass: # TOK_EL_ROT_MAGICCOMBO = 5 # handled by get_ext_level/set_ext_level TOK_EL_ROT_MAGICEXTFUNC = 6 - def test_without_open(self): + def test_without_open(self, model): """Call all the methods that do not depend on open()""" - rot = Hamlib.Rot(ROT_MODEL) + rot = Hamlib.Rot(model) assert rot is not None assert rot.do_exception == 0 assert rot.error_status == Hamlib.RIG_OK @@ -42,14 +40,17 @@ class TestClass: assert isinstance(conf, str) assert rot.set_conf("mcfg", "foo") is None conf = rot.get_conf("mcfg") - assert conf == "foo" + if model == Hamlib.ROT_MODEL_DUMMY: + assert conf == "foo" + else: + assert conf == "" assert rot.token_lookup("") is None - def test_with_open(self): + def test_with_open(self, model): """Call all the methods that depend on open()""" - rot = Hamlib.Rot(ROT_MODEL) + rot = Hamlib.Rot(model) assert rot is not None assert rot.state.comm_state == 0 @@ -106,9 +107,9 @@ class TestClass: assert info is None - def test_object_creation(self): + def test_object_creation(self, model): """Create all objects available""" - rot = Hamlib.Rig(ROT_MODEL) + rot = Hamlib.Rig(model) assert rot is not None assert isinstance(rot.caps, Hamlib.rig_caps)