vendredi 13 octobre 2017

Test for TypeError in python

I want to get TypeError while func have 1 spare param. I try to use asertRaises for that

My func with 3 params:

def a(a, b, c):
    pass

This is how I try to write test:

def er(self):
    fpar = len(inspect.getargspec(a)[0])
    fpar += 1
    b = []
    for x in range(fpar):
        b.append(x)
    a(*b)
    with self.assertRaises(TypeError):
        er(a)

Aucun commentaire:

Enregistrer un commentaire