arcpy.Add Warning could just throw a normal warning. Doe make sense to you people need to do a wrapper every time in a pyt, toolbox and the like just to test?
def scriptwarning(func):
"""
Arcpy Warning Wraper
:param func:
:return:
"""
def wrap(*args, **kwargs):
result = func(*args, **kwargs)
warnings.warn(*args)
return result
return wrap
arcpy.AddWarning = scriptwarning(arcpy.AddWarning)
I don`t like doing it, it seams crazily wrong, for something simple.
If arcpy throws a warning why should I wrap it to test and get an expected warning?
Good idea. But Esri would also have to implement this idea:
Interpret warnings as warnings instead of errors in Python tools
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.