hamlib/bindings/python/conftest.py
Daniele Forsi IU5HKX 0df9d1767e Allow to execute some tests with a simulator or with a real amplifier
To execute the tests with the installed Hamlib use the same long arguments
as ampctl, eg:
 bindings/python/test_amp.py --model {MODEL_NUMBER} --amp-file /dev/ttyUSB0 --serial-speed {BAUD}

To execute the tests from the build tree, add the path to the libraries
that you built, eg. from the root of the build tree:
 PYTHONPATH=bindings/:bindings/.libs/ ...your command...
2025-07-27 12:57:35 +02:00

42 lines
1.7 KiB
Python

"""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
if sys.argv[1].endswith("amp.py"):
parser.addoption('--model', type=int, default=1,
metavar='ID', help='select amplifier model number')
parser.addoption('--amp-file', default=None,
metavar='DEVICE', help='set device of the amplifier 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,
help='set verbose mode, cumulative')
@pytest.fixture
def model(request):
return request.config.getoption("--model")
@pytest.fixture
def rig_file(request):
return request.config.getoption("--rig-file")
@pytest.fixture
def serial_speed(request):
return request.config.getoption("--serial-speed")
@pytest.fixture
def hamlib_verbose(request):
return request.config.getoption("--hamlib-verbose")