def test_write_to_self_exception(self): # _write_to_self() swallows OSError self.loop._csock.send.side_effect = RuntimeError() self.assertRaises(RuntimeError, self.loop._write_to_self)