def test_blockingerror(): try: raise _io.BlockingIOError(42, "test blocking", 123) except OSError as e: assert isinstance(e, _io.BlockingIOError) assert e.errno == 42 assert e.strerror == "test blocking" assert e.characters_written == 123
def test_blockingerror(self): import _io try: raise _io.BlockingIOError(42, "test blocking", 123) except IOError, e: assert isinstance(e, _io.BlockingIOError) assert e.errno == 42 assert e.strerror == "test blocking" assert e.characters_written == 123
def write(self, b): try: b = b.tobytes() except AttributeError: pass n = -1 if self._blocker_char: try: n = b.index(self._blocker_char) except ValueError: pass else: self._blocker_char = None self._write_stack.append(b[:n]) raise _io.BlockingIOError(0, "test blocking", n) self._write_stack.append(b) return len(b)