Pytest: Mocking slow external API call
import externalapi
def compute(x, y):
xx = externalapi.remote_compute(x)
yy = externalapi.remote_compute(y)
result = (xx+yy) ** 0.5
return result
import time
def remote_compute(x):
time.sleep(5) # to imitate long running process
return x*x
import mymath
print(mymath.compute(3, 4))