本文整理汇总了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))
示例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)