dimanche 9 avril 2017

Test functions with Pytest

I have a function ubuntu_data() which scrapes data from a website. I'd like to create tests for this function and to not have it scrape the whole website every time the test is run. I'd like to pass in a string with some data (the kind it reads from the website) to check if the output is correct.

Now, the function doesn't take in any parameters. After it scrapes the website. It creates three lists cve_id, vuln_status & pkg_name and adds the data into them. (The test and the function are in different files, on the same directory)

How can I using pytest and maybe mock do this?

PS: This is what ubuntu_data looks like.

Thanks!

Aucun commentaire:

Enregistrer un commentaire