mardi 31 mars 2020

how to write test function

''' i have found this test code and run in various code and found correct but i am not able to uderstand how it written and what this code block "linenum = sys._getframe(1).f_lineno " is doing and how it is doing it. so please me tell me the working of above shown code block'''

import sys

def test(did_pass): """ Print the result of a test. """ linenum = sys._getframe(1).f_lineno # Get the caller's line number. if did_pass: msg = "Test at line {0} ok.".format(linenum) else: msg = ("Test at line {0} FAILED.".format(linenum)) print(msg)

Aucun commentaire:

Enregistrer un commentaire