本文整理汇总了Python中mozbuild.compilation.warnings.WarningsDatabase.warnings_for_file方法的典型用法代码示例。如果您正苦于以下问题:Python WarningsDatabase.warnings_for_file方法的具体用法?Python WarningsDatabase.warnings_for_file怎么用?Python WarningsDatabase.warnings_for_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozbuild.compilation.warnings.WarningsDatabase
的用法示例。
在下文中一共展示了WarningsDatabase.warnings_for_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pruning
# 需要导入模块: from mozbuild.compilation.warnings import WarningsDatabase [as 别名]
# 或者: from mozbuild.compilation.warnings.WarningsDatabase import warnings_for_file [as 别名]
def test_pruning(self):
"""Ensure old warnings are removed from database appropriately."""
db = WarningsDatabase()
source_files = []
for i in range(1, 21):
temp = NamedTemporaryFile(mode='wt')
temp.write('x' * (100 * i))
temp.flush()
# Keep reference so it doesn't get GC'd and deleted.
source_files.append(temp)
w = CompilerWarning()
w['filename'] = temp.name
w['line'] = 1
w['column'] = i * 10
w['message'] = 'irrelevant'
db.insert(w)
self.assertEqual(len(db), 20)
# If we change a source file, inserting a new warning should nuke the
# old one.
source_files[0].write('extra')
source_files[0].flush()
w = CompilerWarning()
w['filename'] = source_files[0].name
w['line'] = 1
w['column'] = 50
w['message'] = 'replaced'
db.insert(w)
self.assertEqual(len(db), 20)
warnings = list(db.warnings_for_file(source_files[0].name))
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0]['column'], w['column'])
# If we delete the source file, calling prune should cause the warnings
# to go away.
old_filename = source_files[0].name
del source_files[0]
self.assertFalse(os.path.exists(old_filename))
db.prune()
self.assertEqual(len(db), 19)