testing utility function that lets to assert exceptions easily

This is much easier to use than built-in JUnit method-level checks.
junit tests for CannotHaveAttrs