Чтобы смоделировать эту функцию
def myFunction(self):
auth_token_path = self.authTokenPath()
import json
if os.path.exists(auth_token_path):
auth_token = json.load(open(auth_token_path, 'r'))
return auth_token
Все, что нам нужно сделать, это добавить декоратор PATCH (), связанный с функцией импорта, который нужно смоделировать:
@patch('json.load')
def myFunction(self,json):
auth_token_path = self.authTokenPath()
import json
if os.path.exists(auth_token_path):
auth_token = json.load(open(auth_token_path, 'r'))
return auth_token