vendredi 23 juin 2017

How to intercept function call and change parameters with pytest?

Say there's a function download_page_html(url) which downloads the HTML content of the page pointed by (a valid) url. Various functions use it download_page_html to do their jobs.

Now, when testing I don't want to download HTML from Wikipedia but from a localhost.

So how can I intercept the calls made by various functions to download_page_html and replace the url parameter's value?

Aucun commentaire:

Enregistrer un commentaire