-2
async def delete_items(id: str, flag: bool ):
    if not flag:
        raise HTTPException(
            status_code=400,
            detail="set flag as true",
        )
    else:
        return{"message": "All good"}

The test function:

@pytest.mark.anyio
async def test_delete_items():    

       # if flag is False 
        task_id = "valid_task_id"
        flag = False
        response = await delete_items(task_id, flag )`

I want to test the exception this function raises.

0 Answers0