How would you unit test the nested function f1() in the following example?
def f():
def f1():
return 1
return 2
Or should functions that need testing not be nested?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a similar question in this link. But short answer: you can’t access an inner function from an outer element.
For testing purposes, maybe an alternative would be to change the inner function for a private outer one?