I'm implementing a unittest to check if certain strings in an application start with a legal prefix. For example as a test function body I now have:
strings_to_check = ['ID_PRIMARY','ID_FOREIGN','OBJ_NAME', 'SOMETHING_ELSE']
for s in strings_to_check:
assert s.startswith('ID_') or\
s.startswith('OBJ_')
But the AssertionError that is returned is quite verbose (the real code has more legal prefix option). I found this in the documentation, but that focusses on assertion between (custom) objects. Is there a way to write you own custom assertion function that returns a easier to read message?