jeudi 3 septembre 2015

How do you get to the value inside of a python function that returns nothing for unit testing?

I am trying to write a unit test for an existing function:

def _fetch_law(self, task, storage):
    number, link = task
    if not self.silent:
        print 'Requesting page %s' % number
    r = requests.get(link, headers=self.headers)

    if r.status_code != 200:
        sys.exit('CONNECTION ERROR!!! HTTP ERROR %d' % r.status_code)
    vs = LawPages(r.text)
    storage.extend(vs.extract())

For my unit testing, how do I use mocking or other means to get to the final value that is passed to storage ?

Aucun commentaire:

Enregistrer un commentaire