当前位置: 首页>>代码示例>>Python>>正文


Python Qdb.cache_file方法代码示例

本文整理汇总了Python中qdb.Qdb.cache_file方法的典型用法代码示例。如果您正苦于以下问题:Python Qdb.cache_file方法的具体用法?Python Qdb.cache_file怎么用?Python Qdb.cache_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qdb.Qdb的用法示例。


在下文中一共展示了Qdb.cache_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_file_cache_from_string

# 需要导入模块: from qdb import Qdb [as 别名]
# 或者: from qdb.Qdb import cache_file [as 别名]
    def test_file_cache_from_string(self):
        """
        Asserts that manual caching from a string works.
        """
        contents = dedent(
            """\
            line 1
            line 2
            line 3
            line 4
            """
        )
        db = Qdb(cmd_manager=NopCommandManager())
        db.cache_file('file', contents=contents)

        # Check the whole 'file'.
        self.assertEquals(db.get_file('file'), contents[:-1])  # drop '\n'

        for n in range(1, 5):
            # Check all the lines.
            self.assertEquals('line %d' % n, db.get_line('file', n))
开发者ID:OspreyX,项目名称:qdb,代码行数:23,代码来源:test_file_cache.py

示例2: test_file_cache_from_disk

# 需要导入模块: from qdb import Qdb [as 别名]
# 或者: from qdb.Qdb import cache_file [as 别名]
    def test_file_cache_from_disk(self):
        """
        Asserts that the disk caching works.
        """
        # We will use this file, as it is the only file we know that exists.
        # The first time this is run after a change, __file__ will point to
        # the source code file; however, if we run this twice in a row, it
        # points to the byte-compiled file.
        filename = fix_filename(__file__)
        db = Qdb(cmd_manager=NopCommandManager())
        db.cache_file(filename)

        with open(filename) as f:
            contents = f.read()[:-1]  # Drop the last newline.

            # Assert that querying the entire file works.
            self.assertEquals(db.get_file(filename), contents)

            for n, line in zip(count(start=1), contents.splitlines()):
                # Iterate over all the lines of the file, asserting that we
                # have saved them correctly. This also asserts that the line
                # indexing is working as intended.
                self.assertEquals(db.get_line(filename, n), line)
开发者ID:OspreyX,项目名称:qdb,代码行数:25,代码来源:test_file_cache.py


注:本文中的qdb.Qdb.cache_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。