Replace this try block with self.assertRaises