我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用io.IOError()。
def test_nofile(self): # this should probably be supported as a file # but for now test for proper errors b = io.BytesIO() assert_raises(IOError, np.fromfile, b, np.uint8, 80) d = np.ones(7); assert_raises(IOError, lambda x: x.tofile(b), d)
def test_unbuffered_fromfile(self): # gh-6246 self.x.tofile(self.filename) def fail(*args, **kwargs): raise io.IOError('Can not tell or seek') f = io.open(self.filename, 'rb', buffering=0) f.seek = fail f.tell = fail y = np.fromfile(self.filename, dtype=self.dtype) assert_array_equal(y, self.x.flat)
def test_nofile(self): # this should probably be supported as a file # but for now test for proper errors b = io.BytesIO() assert_raises(IOError, np.fromfile, b, np.uint8, 80) d = np.ones(7) assert_raises(IOError, lambda x: x.tofile(b), d)
def test_unbuffered_fromfile(self): # gh-6246 self.x.tofile(self.filename) def fail(*args, **kwargs): raise io.IOError('Can not tell or seek') with io.open(self.filename, 'rb', buffering=0) as f: f.seek = fail f.tell = fail y = np.fromfile(self.filename, dtype=self.dtype) assert_array_equal(y, self.x.flat)