`with self.assertRaises(IOError):` is the standard way to verify exceptions.