I'm trying to use the 'osc_inputs' fixture as a list of params in @pytest.mark.parametrize but it doesn't seem to take a fixture as an argument. Is there anyway of doing this?
Heres the code:
from time import sleep
import pytest
@pytest.fixture()
def osc_inputs(simple_tcp_client):
"""Get all input addresses
Args:
simple_tcp_client: a fixture of type 'SimpleTCPClient' to send and receive messages
"""
simple_tcp_client.sendOSCMessage(address = '/*', value = ["info"])
sleep(0.06)
osc_reply = simple_tcp_client.receive()
return tuple(osc_reply.keys())
@pytest.mark.parametrize("addr", osc_inputs)
def test_osc_init_inputs(simple_tcp_client, addr):
"""Initialize device input variables with osc
Args:
simple_tcp_client: a fixture of type 'SimpleTCPClient'
addr: a fixture of types str OSC address
"""
# TCP - send set OSC message
simple_tcp_client.sendOSCMessage(address = addr, value = ["set", "48v", 0])
simple_tcp_client.sendOSCMessage(address = addr, value = ["set", "mute", 0])
simple_tcp_client.sendOSCMessage(address = addr, value = ["set", "gain", -8.0]) # gain: -8.0 -> 50.0
# TCP - send get OSC message
sleep(0.06)
simple_tcp_client.sendOSCMessage(address = addr, value = ["get"])
sleep(0.06)
osc_reply = simple_tcp_client.receive()
# Check the gain is 0
assert (osc_reply[addr]['gain'][-1] == -8.0)
# Check 48v is off
assert (osc_reply[addr]['48v'][-1] == 0)
# Check mute is off
assert (osc_reply[addr]['mute'][-1] == 0)