'Is it possible to check the call parameters in the test?

is it possible to check in the test with what parameters the method is called and what result it returns, if we call the main method run which calls the method I'm interested in - self.get_request().

file.py

class A:
 def run():
    some logic...
    request = self.get_request()
    some logic...
    return response

test.py

from file.py import A
def test():
   """
   Inside this test, I want to check the parameters and the value returned by the
   get_request method, but I don't want to check it separately
   I want to check it by calling the parent method - run
   """
   instance = A()
   response = instance.run()
   assertions logic for instance.get_request..

I know that it is possible to mock a method and then we have access to the number of calls, parameters, etc. If what I'm asking is possible in some way through mock, I just want to add that my mock would have to have the same logic as the method it mocks (be the same).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source