Fix for TestON silently swallowing errors in testcases
* Print stack traces and error messages
* "ExperimentalHandling" function now also takes unnamed arguments. Needs more work to parse them for experimental mode
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 3f07691..fa2c488 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -240,8 +240,10 @@
exec code[testCaseNumber][step] in module.__dict__
self.stepCount = self.stepCount + 1
except TypeError,e:
+ print "Exception in the following section of code:"
+ print code[testCaseNumber][step]
self.stepCount = self.stepCount + 1
- self.log.error(e)
+ self.log.exception(e)
return main.TRUE
if cli.stop:
@@ -442,8 +444,8 @@
try :
import json
response_dict = json.loads(response)
- except Exception , e :
- print e
+ except Exception, e:
+ main.log.exception(e)
main.log.error("Json Parser is unable to parse the string")
return response_dict
@@ -461,7 +463,7 @@
try :
response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
except Exception, e:
- main.log.error(e)
+ main.log.exception(e)
return response_dict
def dict_to_return_format(self,response,return_format,response_dict):
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index 1e87d03..503acbe 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -23,9 +23,6 @@
"""
-import re
-from logging import Logger
-
class Component( object ):
@@ -39,26 +36,29 @@
def __getattr__( self, name ):
"""
This will invoke, if the attribute wasn't found the usual ways.
- Here it will look for assert_attribute and will execute when AttributeError occurs.
- It will return the result of the assert_attribute.
+ Here it will look for assert_attribute and will execute when
+ AttributeError occurs.
+ It will return the result of the assert_attribute.
"""
try:
return getattr( self.wrapped, name )
- except AttributeError:
+ except AttributeError as error:
+ main.log.error( str(error.__class__) + " " + str(error) )
try:
- def experimentHandling( **kwargs ):
+ def experimentHandling( *args, **kwargs ):
if main.EXPERIMENTAL_MODE == main.TRUE:
- result = self.experimentRun( **kwargs )
- main.log.info( "EXPERIMENTAL MODE. API " + str(
- name ) + " not yet implemented. Returning dummy values" )
+ result = self.experimentRun( *args, **kwargs )
+ main.log.info( "EXPERIMENTAL MODE. API " +
+ str( name ) +
+ " not yet implemented. " +
+ "Returning dummy values" )
return result
else:
return main.FALSE
return experimentHandling
except TypeError as e:
- main.log.error(
- "Arguments for experimental mode does not have key 'retruns'" +
- e )
+ main.log.error( "Arguments for experimental mode does not" +
+ " have key 'retruns'" + e )
def connect( self ):
@@ -110,7 +110,8 @@
def get_version( self ):
return "Version unknown"
- def experimentRun( self, **kwargs ):
+ def experimentRun( self, *args, **kwargs ):
+ # FIXME handle *args
args = utilities.parse_args( [ "RETURNS" ], **kwargs )
return args[ "RETURNS" ]