當前位置: 首頁>>代碼示例>>Python>>正文


Python os.SEEK_DATA屬性代碼示例

本文整理匯總了Python中os.SEEK_DATA屬性的典型用法代碼示例。如果您正苦於以下問題:Python os.SEEK_DATA屬性的具體用法?Python os.SEEK_DATA怎麽用?Python os.SEEK_DATA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在os的用法示例。


在下文中一共展示了os.SEEK_DATA屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_fs_holes

# 需要導入模塊: import os [as 別名]
# 或者: from os import SEEK_DATA [as 別名]
def test_fs_holes(self):
        # Even if the filesystem doesn't report holes,
        # if the OS supports it the SEEK_* constants
        # will be defined and will have a consistent
        # behaviour:
        # os.SEEK_DATA = current position
        # os.SEEK_HOLE = end of file position
        with open(support.TESTFN, 'r+b') as fp:
            fp.write(b"hello")
            fp.flush()
            size = fp.tell()
            fno = fp.fileno()
            try :
                for i in range(size):
                    self.assertEqual(i, os.lseek(fno, i, os.SEEK_DATA))
                    self.assertLessEqual(size, os.lseek(fno, i, os.SEEK_HOLE))
                self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_DATA)
                self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_HOLE)
            except OSError :
                # Some OSs claim to support SEEK_HOLE/SEEK_DATA
                # but it is not true.
                # For instance:
                # http://lists.freebsd.org/pipermail/freebsd-amd64/2012-January/014332.html
                raise unittest.SkipTest("OSError raised!") 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:26,代碼來源:test_posix.py

示例2: test_seek_unsupported

# 需要導入模塊: import os [as 別名]
# 或者: from os import SEEK_DATA [as 別名]
def test_seek_unsupported(self, pyqiodev):
        """Test seeking with unsupported whence arguments."""
        # pylint: disable=no-member,useless-suppression
        if hasattr(os, 'SEEK_HOLE'):
            whence = os.SEEK_HOLE
        elif hasattr(os, 'SEEK_DATA'):
            whence = os.SEEK_DATA
        # pylint: enable=no-member,useless-suppression
        else:
            pytest.skip("Needs os.SEEK_HOLE or os.SEEK_DATA available.")
        pyqiodev.open(QIODevice.ReadOnly)
        with pytest.raises(io.UnsupportedOperation):
            pyqiodev.seek(0, whence) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:15,代碼來源:test_qtutils.py


注:本文中的os.SEEK_DATA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。