本文整理汇总了Python中resourceful.NeededResources.resources方法的典型用法代码示例。如果您正苦于以下问题:Python NeededResources.resources方法的具体用法?Python NeededResources.resources怎么用?Python NeededResources.resources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resourceful.NeededResources
的用法示例。
在下文中一共展示了NeededResources.resources方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mode_fully_specified
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_mode_fully_specified():
foo = Library('foo', '')
k_debug = Resource(foo, 'k-debug.js')
k = Resource(foo, 'k.js', debug=k_debug)
needed = NeededResources()
needed.need(k)
assert needed.resources() == [k]
needed = NeededResources(debug=True)
needed.need(k)
assert needed.resources() == [k_debug]
# If no minified can be found, the 'raw' resource is taken.
needed = NeededResources(minified=True)
needed.need(k)
assert needed.resources() == [k]
with pytest.raises(ConfigurationError):
NeededResources(debug=True, minified=True)
# If only a minified resource is defined, debug returns the raw version.
x = Resource(foo, 'x.js', minified='x-min.js')
needed = NeededResources(debug=True)
needed.need(x)
assert needed.resources() == [x]
示例2: test_rollup_cannot
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_rollup_cannot():
foo = Library('foo', '')
b1 = Resource(foo, 'b1.js')
b2 = Resource(foo, 'b2.js')
giant = Resource(foo, 'giant.js', supersedes=[b1, b2])
needed = NeededResources(rollup=True)
needed.need(b1)
assert needed.resources() == [b1]
assert giant not in needed.resources()
示例3: test_mode_shortcut
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_mode_shortcut():
foo = Library('foo', '')
k = Resource(foo, 'k.js', debug='k-debug.js')
needed = NeededResources()
needed.need(k)
assert needed.resources() == [k]
needed = NeededResources(debug=True)
needed.need(k)
assert len(needed.resources()) == 1
assert needed.resources()[0].relpath == 'k-debug.js'
示例4: test_dont_fill_required_slot
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_dont_fill_required_slot():
needed = NeededResources()
lib = Library('lib', '')
slot = Slot(lib, '.js')
a = Resource(lib, 'a.js', depends=[slot])
b = Resource(lib, 'b.js')
needed.need(a)
with pytest.raises(SlotError):
needed.resources()
示例5: test_fill_slot_wrong_extension
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_fill_slot_wrong_extension():
needed = NeededResources()
lib = Library('lib', '')
slot = Slot(lib, '.js')
a = Resource(lib, 'a.js', depends=[slot])
b = Resource(lib, 'b.css')
needed.need(a, {slot: b})
with pytest.raises(SlotError):
needed.resources()
示例6: test_redundant_more_complicated
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_redundant_more_complicated():
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])
needed = NeededResources()
needed.need(a3)
assert needed.resources() == [a1, a2, a3]
needed.need(a4)
# a4 is sorted before a3, because it is less deep
# in the dependency tree
assert needed.resources() == [a1, a2, a4, a3]
示例7: test_rollup_size_competing
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_rollup_size_competing():
foo = Library('foo', '')
d1 = Resource(foo, 'd1.js')
d2 = Resource(foo, 'd2.js')
d3 = Resource(foo, 'd3.js')
giant = Resource(foo, 'giant.js', supersedes=[d1, d2])
giant_bigger = Resource(foo, 'giant-bigger.js',
supersedes=[d1, d2, d3])
needed = NeededResources(rollup=True)
needed.need(d1)
needed.need(d2)
needed.need(d3)
assert needed.resources() == [giant_bigger]
assert giant not in needed.resources()
示例8: test_library_ordering_bug
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_library_ordering_bug():
jquery_lib = Library('jquery', '')
jqueryui_lib = Library('jqueryui', '')
obviel_lib = Library('obviel', '')
bread_lib = Library('bread', '')
app_lib = Library('app', '')
jquery = Resource(jquery_lib, 'jquery.js')
jqueryui = Resource(jqueryui_lib, 'jqueryui.js', depends=[jquery])
obviel = Resource(obviel_lib, 'obviel.js', depends=[jquery])
obviel_forms = Resource(obviel_lib, 'obviel_forms.js',
depends=[obviel])
obviel_datepicker = Resource(obviel_lib, 'obviel_datepicker.js',
depends=[obviel_forms, jqueryui])
vtab = Resource(bread_lib, 'vtab.js', depends=[jqueryui])
tabview = Resource(bread_lib, 'tabview.js', depends=[obviel, vtab])
bread = Resource(bread_lib, 'bread.js', depends=[tabview, obviel_forms])
app = Resource(app_lib, 'app.js', depends=[bread, obviel_datepicker])
needed = NeededResources()
needed.need(app)
resources = needed.resources()
for resource in resources:
print((resource, resource.library.library_nr))
assert resources == [jquery, jqueryui, obviel, obviel_forms,
obviel_datepicker, vtab, tabview, bread, app]
示例9: test_rollup_modes
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_rollup_modes():
foo = Library('foo', '')
f1 = Resource(foo, 'f1.js', debug='f1-debug.js')
f2 = Resource(foo, 'f2.js', debug='f2-debug.js')
giantf = Resource(foo, 'giantf.js', supersedes=[f1, f2],
debug='giantf-debug.js')
needed = NeededResources(rollup=True)
needed.need(f1)
needed.need(f2)
assert needed.resources() == [giantf]
needed = NeededResources(rollup=True, debug=True)
needed.need(f1)
needed.need(f2)
assert needed.resources() == [giantf.modes['debug']]
示例10: test_redundant_resource
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_redundant_resource():
foo = Library('foo', '')
x1 = Resource(foo, 'a.js')
x2 = Resource(foo, 'b.css')
y1 = Resource(foo, 'c.js', depends=[x1, x2])
needed = NeededResources()
needed.need(y1)
needed.need(y1)
assert needed.resources() == [x2, x1, y1]
needed.need(x1)
assert needed.resources() == [x2, x1, y1]
needed.need(x2)
assert needed.resources() == [x2, x1, y1]
示例11: test_bundle_single_dont_bundle_entry
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_bundle_single_dont_bundle_entry():
foo = Library('foo', '')
a = Resource(foo, 'a.js', dont_bundle=True)
needed = NeededResources(bundle=True)
needed.need(a)
resources = needed.resources()
assert resources == [a]
示例12: test_rollup_without_mode
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_rollup_without_mode():
foo = Library('foo', '')
h1 = Resource(foo, 'h1.js', debug='h1-debug.js')
h2 = Resource(foo, 'h2.js', debug='h2-debug.js')
gianth = Resource(foo, 'gianth.js', supersedes=[h1, h2])
needed = NeededResources(resources=[h1, h2], rollup=True, debug=True)
# no mode available for rollup, use the rollup.
assert needed.resources() == [gianth]
示例13: test_slot_with_default_uses_default_if_nothing_given_in_need
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_slot_with_default_uses_default_if_nothing_given_in_need():
needed = NeededResources()
lib = Library('lib', '')
default_resource_for_slot = Resource(lib, 'b.js')
slot = Slot(lib, '.js', default=default_resource_for_slot)
a = Resource(lib, 'a.js', depends=[slot])
needed.need(a)
relpaths = [r.relpath for r in needed.resources()]
assert relpaths == ['b.js', 'a.js']
示例14: test_rollup_larger
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_rollup_larger():
foo = Library('foo', '')
c1 = Resource(foo, 'c1.css')
c2 = Resource(foo, 'c2.css')
c3 = Resource(foo, 'c3.css')
giant = Resource(foo, 'giant.css', supersedes=[c1, c2, c3])
needed = NeededResources(rollup=True)
needed.need(c1)
assert needed.resources() == [c1]
needed.need(c2)
assert needed.resources() == [c1, c2]
needed.need(c3)
assert needed.resources() == [giant]
示例15: test_bundle_single_entry
# 需要导入模块: from resourceful import NeededResources [as 别名]
# 或者: from resourceful.NeededResources import resources [as 别名]
def test_bundle_single_entry():
# we can successfully bundle a single resource (it's not bundled though)
foo = Library('foo', '')
a = Resource(foo, 'a.js')
needed = NeededResources(bundle=True)
needed.need(a)
resources = needed.resources()
assert resources == [a]