Use assertRaisesRegexp instead of try except pattern