In the below script i would like to parametrize functions call RegisterClientCabinMovementDetection(x)
and RegisterClientOccupantInSeatDetection(x)
(made bold in script)so on... is there any way to parametrize function in pytest ?
@pytest.mark.asyncio
@pytest.mark.parametrize('Qf, expected',[(UNDEFINED,"Invalid"),(INPROGRESS,"InProgress"),(NOTSPECIFIED,"NotOk"),(DATAOK,"DataOK")])
@pytest.mark.parametrize('Detection, expected_Detection',[(UNDEFINED,"Undefined"),(NOTDETECTED,"NotDetected"),(DETECTED,"Detected")])
@pytest.mark.parametrize('AvailabilityStatus,expected_availablity',[(UNDEFINED,"Undefined"),(NOTAVAILABLE,"NotAvailable"),(AVAILABLE,"Available"),(FAULT,"Fault"),(POSITIONNOTPRESENT,"PositionNotPresent")])
async def test_occupant_presence(snok,Qf,expected,Detection,expected_Detection,AvailabilityStatus,expected_availablity):
""" Function to test occupant presence condition with driver available available scenario"""
#setup
occupant_presence_mock = snok.get_service("occupant_presence_hal")
occupant_presence_service = snok.get_service("OccupantPresenceProvider")
#Act
await occupant_presence_service.**RegisterClientCabinMovementDetection(0)**
#await occupant_presence_service.**RegisterClientOccupantInSeatDetection(0)**
snok.async_sleep(1)
seat_sensor_status =driver_not_detected_in_seat(occupant_presence_mock,Qf,Detection,AvailabilityStatus)
await occupant_presence.set_DriverSeatCabinMovementDetection(seat_sensor_status)
snok.async_sleep(1)
response = await occupant_presence_service.get_DriverSeatCabinMovementDetection()
#response = await occupant_presence_service.get_DriverSeatOccupantInSeatDetection()
response_quality_factor=str(response.quality_factor)
quality_factor_value = response_quality_factor.split('.')
presence_detection_value= str(response.presence_detection).split('.')
detector_status_value = str(response.detector_status).split('.')
#assert
assert quality_factor_value[1] == expected
assert presence_detection_value[1] == expected_Detection
assert detector_status_value[1] == expected_availablity
Unable to parametrize function call so code is going much bigger . Is there any way to reduce the lines of code using parametrize function in pytest ?