Python io 模块,IOError() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用io.IOError()

项目:radar    作者:amoose136    | 项目源码 | 文件源码
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)
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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)