本文整理汇总了Python中fanstatic.NeededResources.clear方法的典型用法代码示例。如果您正苦于以下问题:Python NeededResources.clear方法的具体用法?Python NeededResources.clear怎么用?Python NeededResources.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fanstatic.NeededResources
的用法示例。
在下文中一共展示了NeededResources.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clear
# 需要导入模块: from fanstatic import NeededResources [as 别名]
# 或者: from fanstatic.NeededResources import clear [as 别名]
def test_clear():
foo = Library('foo', '')
a1 = Resource(foo, 'a1.js')
a2 = Resource(foo, 'a2.js', depends=[a1])
a3 = Resource(foo, 'a3.js', depends=[a2])
a4 = Resource(foo, 'a4.js', depends=[a1])
a5 = Resource(foo, 'a5.js', depends=[a4, a3])
needed = NeededResources(resources=[a1, a2, a3])
assert needed.resources() == set([a1, a2, a3])
# For some reason,for example an error page needs to be rendered,
# the currently needed resources need to be cleared.
needed.clear()
assert len(needed.resources()) == 0
needed.need(a4)
needed.need(a5)
assert needed.resources() == set([a1, a2, a4, a3, a5])