This function distinguishes between expected runtime errors, and errors caused
by bad code in the given string. Parse errors and related problems should
always result in the test failing. Expected runtime errors are necessary to
fully cover pathways in the Python bindings.