本文整理汇总了Python中pyramid_webassets.get_webassets_env_from_settings函数的典型用法代码示例。如果您正苦于以下问题:Python get_webassets_env_from_settings函数的具体用法?Python get_webassets_env_from_settings怎么用?Python get_webassets_env_from_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_webassets_env_from_settings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_webassets_env_from_settings_no_base_dir
def test_get_webassets_env_from_settings_no_base_dir(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {'webassets.base_url': '/static'}
with self.assertRaises(Exception) as cm:
get_webassets_env_from_settings(settings)
assert cm.exception.message == "You need to provide webassets.base_dir in your configuration"
示例2: test_get_webassets_env_from_settings_no_base_url
def test_get_webassets_env_from_settings_no_base_url(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {'webassets.base_dir': '/home'}
with self.assertRaises(Exception) as cm:
get_webassets_env_from_settings(settings)
assert str(cm.exception) == "You need to provide webassets.base_url in your configuration"
示例3: test_get_webassets_env_from_settings_prefix_bad_change
def test_get_webassets_env_from_settings_prefix_bad_change(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'foo.base_url': 'static',
'foo.base_dir': os.getcwd(),
}
with self.assertRaises(Exception) as cm:
get_webassets_env_from_settings(settings, prefix='webassets')
assert str(cm.exception) == "You need to provide webassets.base_dir in your configuration"
示例4: test_get_webassets_env_from_settings_prefix_bad_change
def test_get_webassets_env_from_settings_prefix_bad_change(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'foo.base_url': '/static',
'foo.base_dir': '/home/sontek',
}
with self.assertRaises(Exception) as cm:
get_webassets_env_from_settings(settings, prefix='webassets')
assert cm.exception.message == "You need to provide webassets.base_dir in your configuration"
示例5: test_bundles_yamlloader_asset
def test_bundles_yamlloader_asset(self):
try:
import yaml
except ImportError:
raise unittest.SkipTest('PyYAML not installed')
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': os.getcwd(),
'webassets.bundles': (
'dotted.package.name:foo/bar.yaml\n'
'dotted.package.name:foo/baz.yaml'
),
}
self.create_files({
'dotted/__init__.py': '',
'dotted/package/__init__.py': '',
'dotted/package/name/__init__.py': '',
'dotted/package/name/foo/bar.yaml': (
'mycss: {contents: style/mycssoverride.css}'
),
'dotted/package/name/foo/baz.yaml': (
'mycss: {contents: style/mycss.css}\n'
'myjs: {contents: js/myjs.js}'
),
})
env = get_webassets_env_from_settings(settings)
self.assertEqual(env.config.get('bundles'), None)
self.assertIsNotNone(env['mycss'])
self.assertEqual(sorted(env._named_bundles.keys()), ['mycss', 'myjs'])
self.assertIn('style/mycssoverride.css', env['mycss'].contents)
示例6: test_auto_bool
def test_auto_bool(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': os.getcwd(),
'webassets.less_run_in_debug': 'true',
}
env = get_webassets_env_from_settings(settings)
assert env.config['less_run_in_debug'] is True
示例7: test_auto_json
def test_auto_json(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': os.getcwd(),
'webassets.less_extra_args': 'json:["--foo", "--bar"]',
}
env = get_webassets_env_from_settings(settings)
assert env.config['less_extra_args'] == ['--foo', '--bar']
示例8: test_get_webassets_env_from_settings_load_path
def test_get_webassets_env_from_settings_load_path(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': os.getcwd(),
'webassets.load_path': '/foo bar/\nbaz'
}
env = get_webassets_env_from_settings(settings)
assert env.load_path == ['/foo', 'bar/', 'baz']
示例9: test_get_webassets_env_from_settings_minimal
def test_get_webassets_env_from_settings_minimal(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': '/static',
'webassets.base_dir': os.getcwd(),
}
env = get_webassets_env_from_settings(settings)
assert env.directory == settings['webassets.base_dir']
assert env.url == settings['webassets.base_url']
示例10: test_get_webassets_env_from_settings_with_cache
def test_get_webassets_env_from_settings_with_cache(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': '/static',
'webassets.base_dir': '/home/sontek',
'webassets.cache': 'true',
}
env = get_webassets_env_from_settings(settings)
assert env.cache != None
示例11: test_get_webassets_env_from_settings_with_cache
def test_get_webassets_env_from_settings_with_cache(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': os.getcwd(),
'webassets.cache': 'true',
}
env = get_webassets_env_from_settings(settings)
assert env.cache is not None
示例12: test_get_webassets_env_from_settings_asset_spec_dir
def test_get_webassets_env_from_settings_asset_spec_dir(self):
import pyramid_webassets
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': 'pyramid_webassets:static',
}
env = get_webassets_env_from_settings(settings)
expected = os.path.join(pyramid_webassets.__path__[0], 'static')
assert env.directory == expected
示例13: test_get_webassets_env_from_settings_prefix_change
def test_get_webassets_env_from_settings_prefix_change(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'foo.base_url': '/static',
'foo.base_dir': '/home/sontek',
}
env = get_webassets_env_from_settings(settings, prefix='foo')
assert env != None
assert env.directory == settings['foo.base_dir']
assert env.url == settings['foo.base_url']
示例14: test_get_webassets_env_from_settings_dir_with_colon
def test_get_webassets_env_from_settings_dir_with_colon(self):
import pyramid_webassets
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': 'here:static',
}
env = get_webassets_env_from_settings(settings)
expected = os.path.abspath('here:static')
assert env.directory == expected
示例15: test_webassets_static_view_setting
def test_webassets_static_view_setting(self):
from pyramid_webassets import get_webassets_env_from_settings
settings = {
'webassets.base_url': 'static',
'webassets.base_dir': os.getcwd(),
'webassets.static_view': True,
}
env = get_webassets_env_from_settings(settings)
assert env is not None
assert env.config['static_view'] == settings['webassets.static_view']