May-11-2019, 03:18 AM
Passing lists and dictionaries to functions is done using the asterisk and double asterisk syntax respectively. Here is a simple demo program to show you how it works:
I hope this helps. I'm going by the title of the thread. I know what unittest is, though I've never used it, I don't know what Appium code is and I am unfamiliar with about half the libraries you're using. If all you needed was to know how to pass dictionaries to functions, here you go.
def aFunc (param1, param2, param3): print("This is param1: {}".format(param1)) print("This is param2: {}".format(param2)) print("This is param3: {}".format(param3)) paramDict = {"param1": "I am param1!", "param2": "I am param2!", "param3": "I am param3!"} aFunc(**paramDict) print("\n") paramList = ["I am param1!", "I am param2!", "I am param3!"] aFunc(*paramList)
Output:This is param1: I am param1
This is param2: I am param2
This is param3: I am param3
This is param1: I am param1
This is param2: I am param2
This is param3: I am param3
Using the single asterisk syntax on dictionaries passes the keys to the function. Single asterisk also works with tuples.I hope this helps. I'm going by the title of the thread. I know what unittest is, though I've never used it, I don't know what Appium code is and I am unfamiliar with about half the libraries you're using. If all you needed was to know how to pass dictionaries to functions, here you go.