testing-debugging/quickref.tex
changeset 522 d33698326409
parent 521 88a01948450d
child 523 54bdda4aefa5
equal deleted inserted replaced
521:88a01948450d 522:d33698326409
     1 Skeleton of a test:\\
       
     2 {\ex \lstinline| if __name__ == '__main__':|}
       
     3 {\ex \lstinline|      result = gcd(48, 64) |}  
       
     4 {\ex \lstinline|      if result != 16:     |}
       
     5 {\ex \lstinline|           print ``Test Failed'' |}
       
     6 {\ex \lstinline|      print ``Test Passed''      |}
       
     7 
       
     8 
       
     9 \textbf{Testing}
       
    10 
       
    11 Get results from function or unit of code being tested.Compare it to original output. Test passed if they match else failed.
       
    12 
       
    13 \textbf{Code Style} 
       
    14 Four Space Indentation
       
    15 79 character limit on a line
       
    16 Funtions should be seperated by 
       
    17 blank line
       
    18 Use Docstring
       
    19 White space around operators 
       
    20    
       
    21 Skeleton of try catch:\\
       
    22 {\ex \lstinline|     try:                  |}
       
    23 {\ex \lstinline|      	  num = int(a)     |}
       
    24 {\ex \lstinline|     except:               |}
       
    25 {\ex \lstinline|         print ``Wrong input...'' |}
       
    26 
       
    27 Starting debugger in ipython:\\
       
    28 {\ex \lstinline|     %debug                  |}