I'm using assert multiple times throughout multiple scripts, I was wondering if anyone has any suggestions on a better way to achieve this instead of the functions I have created below.
def assert_validation(expected, actual, type='', message=''):
if type == '==':
assert expected == actual, 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
elif type == '!=':
assert expected != actual, 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
elif type == '<=':
assert expected <= actual, 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
elif type == '>=':
assert expected >= actual, 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
def assert_str_validation(expected, actual, type='', message=''):
if type == '==':
assert str(expected) == str(actual), 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
elif type == '!=':
assert str(expected) != str(actual), 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
elif type == '<=':
assert str(expected) <= str(actual), 'Expected: %s, Actual: %s, %s' %(expected, actual, message)
elif type == '>=':
assert str(expected) >= str(actual), 'Expected: %s, Actual: %s, %s' %(expected, actual, message)