mardi 21 février 2017

Testing python function with list of arguments for exceptions

I know pretty nothing about testing so need your help.

Got a python function that is being changed from time to time. Also there is a list of arguments that this function should handle with no exceptions. So the question - how to make correct simple test for this.

I need something like

for arg in args:
    cmd = 'python script.py %s' % arg
    p = subprocess.Popen(cmd, shell = True, 
        stdout = subprocess.PIPE, stderr = subprocess.PIPE)
    output, err = p.communicate()
    if err:
        print arg
        print err

Is it OK to do it with such self-written script or are there any special modules for this?

Or what is the best way to deal with it?

Aucun commentaire:

Enregistrer un commentaire