Replaced try...catch within tests with pytest.raises

This still leaves one in test_debug which relies on reading out
the traceback and cannot easily be replaced by pytest.raises
like the others.
6 files changed