I have a method call getKey() returning url and key and I need to test the function using python unittest.mock
def getKey(): key = "xxxxx" url = 'www.test.com' return url,key
Can you explain further? What do you mean when you say you "need to test the function using unittest.mock"? Is the function really as simple as the code you've shown? Do you really mean you're testing something else and you need to provide a mocked implementation of this function?
Can you show the kinds of tests you're trying to write?
At this point, it's really not clear what you're trying to do.
I need to create a def test for that method with a mock data. that's all
I didn't write that; you need to fix that post.
What does the function do? Is it getting the data from somewhere? Where? If the values are just hardcoded in the test, what value is there in testing it? If you're going to just mock the function, you're not really testing it, either. Of course, the other thing is that you shouldn't put your secret values like API keys in code anyway, as you'll end up storing them in version control and anyone with access to the code will have them (e.g. if the repo is compromised).