lundi 4 mai 2020

How can I write testing function for closure (nested function)? [duplicate]

I'm trying to write testing function for my this function. Here something can be wrong, but I want to understand that how can I call these two functions.

def base_func(high, low):
    """checking something"""
    def second_func(instance, attribute, val):
        if not high <= val <= low:
            raise ValueError('something went wrong')
    return second_func

This is my closure's nested function. So I need to call base_func and after that my return second_func.

@pytest.mark.parametrize('...,expected_result',
                     [()])
def test_func(…, expected _result):

What should I write in my test function? How can I call them? And do I need in my pytest.mark.parametrize part, define my all arguments (high,low,intsance,attribute,val)?

Aucun commentaire:

Enregistrer un commentaire