Merge pull request #130 from opennetworkinglab/devl/pexpect_fix

Devl/pexpect fix
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index fc85c55..271c0dd 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -264,6 +264,8 @@
                     self.log.wiki( "<li>" + line + "  <ac:emoticon ac:name=\"cross\" /></li>\n" )
                 elif re.search( " - No Result$", line ):
                     self.log.wiki( "<li>" + line + "  <ac:emoticon ac:name=\"warning\" /></li>\n" )
+                else:  # Should only be on fail message
+                    self.log.wiki( "<ul><li>" + line + "</li></ul>\n" )
             self.log.wiki( "</ul>" )
             self.log.summary( self.stepCache )
             self.stepCache = ""
@@ -274,19 +276,19 @@
             try :
                 step = stepList[self.stepCount]
                 self.STEPRESULT = self.NORESULT
+                self.onFailMsg = "\t\tNo on fail message given"
                 exec code[testCaseNumber][step] in module.__dict__
                 self.stepCount = self.stepCount + 1
                 if step > 0:
                     self.stepCache += "\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - "
                     if self.STEPRESULT == self.TRUE:
                         self.stepCache += "PASS\n"
-                        #self.stepCache += "PASS  <ac:emoticon ac:name=\"tick\" /></li>\n"
                     elif self.STEPRESULT == self.FALSE:
                         self.stepCache += "FAIL\n"
-                        #self.stepCache += "FAIL  <ac:emoticon ac:name=\"cross\" /></li>\n"
+                        # TODO: Print the on-fail statement here
+                        self.stepCache += "\t\t" + self.onFailMsg + "\n"
                     else:
                         self.stepCache += "No Result\n"
-                        #self.stepCache += "No Result  <ac:emoticon ac:name=\"warning\" /></li>\n"
                     self.stepResults.append(self.STEPRESULT)
             except StandardError as e:
                 self.log.exception( "\nException in the following section of" +
@@ -304,6 +306,8 @@
                         self.log.wiki( "<li>" + line + "  <ac:emoticon ac:name=\"cross\" /></li>\n" )
                     elif re.search( " - No Result$", line ):
                         self.log.wiki( "<li>" + line + "  <ac:emoticon ac:name=\"warning\" /></li>\n" )
+                    else:  # Should only be on fail message
+                        self.log.wiki( "<ul><li>" + line + "</li></ul>\n" )
                 self.log.wiki( "</ul>" )
                 #summary results
                 self.log.summary( self.stepCache )
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index dda43bf..1ba403d 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -84,27 +84,27 @@
                 return result
             return assertHandling
 
-    def _assert (self,**assertParam):  
+    def _assert (self,**assertParam):
         '''
         It will take the arguments :
-        expect:'Expected output' 
-        actual:'Actual output' 
+        expect:'Expected output'
+        actual:'Actual output'
         onpass:'Action or string to be triggered or displayed respectively when the assert passed'
         onfail:'Action or string to be triggered or displayed respectively when the assert failed'
         not:'optional argument to specify the negation of the each assertion type'
         operator:'assertion type will be defined by using operator. Like equal , greater, lesser, matches.'
-        
+
         It will return the assertion result.
-                
+
         '''
-              
+
         arguments = self.parse_args(["EXPECT","ACTUAL","ONPASS","ONFAIL","NOT","OPERATOR"],**assertParam)
-        
+
         result = 0
         valuetype = ''
         operation = "not "+ str(arguments["OPERATOR"]) if arguments['NOT'] and arguments['NOT'] == 1 else arguments["OPERATOR"]
         operators = {'equals':{'STR':'==','NUM':'=='}, 'matches' : '=~', 'greater':'>' ,'lesser':'<'}
-           
+
         expectMatch = re.match('^\s*[+-]?0(e0)?\s*$', str(arguments["EXPECT"]), re.I+re.M)
         if not ((not expectMatch) and (arguments["EXPECT"]==0)):
             valuetype = 'NUM'
@@ -112,31 +112,30 @@
             if arguments["OPERATOR"] == 'greater' or arguments["OPERATOR"] == 'lesser':
                 main.log.error("Numeric comparison on strings is not possibele")
                 return main.ERROR
-            
+
         valuetype = 'STR'
         arguments["ACTUAL"] = str(arguments["ACTUAL"])
         if arguments["OPERATOR"] != 'matches':
             arguments["EXPECT"] = str(arguments["EXPECT"])
- 
+
         try :
             opcode = operators[str(arguments["OPERATOR"])][valuetype] if arguments["OPERATOR"] == 'equals' else operators[str(arguments["OPERATOR"])]
-            
+
         except KeyError:
             print "Key Error in assertion"
             return main.FALSE
-        
+
         if opcode == '=~':
             try:
                 assert re.search(str(arguments["EXPECT"]),str(arguments["ACTUAL"]))
                 result = main.TRUE
             except AssertionError:
                 try :
-                    assert re.match(str(arguments["EXPECT"]),str(arguments["ACTUAL"])) 
+                    assert re.match(str(arguments["EXPECT"]),str(arguments["ACTUAL"]))
                     result = main.TRUE
                 except AssertionError:
                     main.log.error("Assertion Failed")
                     result = main.FALSE
-                    
         else :
             try:
                 if str(opcode)=="==":
@@ -145,27 +144,21 @@
                         result = main.TRUE
                     else :
                         result = main.FALSE
-                        
                 elif str(opcode) == ">":
                     main.log.info("Verifying the Expected is Greater than the actual or not using assert_greater")
                     if (ast.literal_eval(arguments["EXPECT"]) > ast.literal_eval(arguments["ACTUAL"])) :
                         result = main.TRUE
                     else :
                         result = main.FALSE
-                        
                 elif str(opcode) == "<":
                     main.log.info("Verifying the Expected is Lesser than the actual or not using assert_lesser")
                     if (ast.literal_eval(arguments["EXPECT"]) < ast.literal_eval(arguments["ACTUAL"])):
                         result = main.TRUE
                     else :
                         result = main.FALSE
-                    
-                    
             except AssertionError:
                 main.log.error("Assertion Failed")
                 result = main.FALSE
-                
-        
         result = result if result else 0
         result = not result if arguments["NOT"] and arguments["NOT"] == 1 else result
         resultString = ""
@@ -179,7 +172,8 @@
             else :
                 main.log.error(arguments["ONFAIL"])
                 main.log.report(arguments["ONFAIL"])
-             
+                main.onFailMsg = arguments[ 'ONFAIL' ]
+
         msg = arguments["ON" + str(resultString)]
 
         if not isinstance(msg,str):
@@ -190,8 +184,7 @@
 
         main.last_result = result
         return result
-    
-    
+
     def parse_args(self,args, **kwargs):
         '''
         It will accept the (key,value) pair and will return the (key,value) pairs with keys in uppercase.
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 44552ae..3b94ef7 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -81,7 +81,7 @@
         while i == 5:
             i = self.handle.expect( [
 				    ssh_newkey,
-                                    'password:',
+                                    'password:|Password:',
                                     pexpect.EOF,
                                     pexpect.TIMEOUT,
                                     refused,