[tests] Avoid deprecated except syntax.