本文整理匯總了Python中static_precompiler.compilers.LESS.compile_source方法的典型用法代碼示例。如果您正苦於以下問題:Python LESS.compile_source方法的具體用法?Python LESS.compile_source怎麽用?Python LESS.compile_source使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類static_precompiler.compilers.LESS
的用法示例。
在下文中一共展示了LESS.compile_source方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_compile_source
# 需要導入模塊: from static_precompiler.compilers import LESS [as 別名]
# 或者: from static_precompiler.compilers.LESS import compile_source [as 別名]
def test_compile_source():
compiler = LESS()
assert compiler.compile_source("p {font-size: 15px; a {color: red;}}") == "p {\n font-size: 15px;\n}\np a {\n color: red;\n}\n"
with pytest.raises(StaticCompilationError):
compiler.compile_source('invalid syntax')
# Test non-ascii
NON_ASCII = """.external_link:first-child:before {
content: "Zobacz także:";
background: url(картинка.png);
}
"""
assert compiler.compile_source(NON_ASCII) == NON_ASCII
示例2: test_compile_source
# 需要導入模塊: from static_precompiler.compilers import LESS [as 別名]
# 或者: from static_precompiler.compilers.LESS import compile_source [as 別名]
def test_compile_source(self):
compiler = LESS()
self.assertEqual(
compiler.compile_source("p {font-size: 15px; a {color: red;}}"),
"p {\n font-size: 15px;\n}\np a {\n color: red;\n}\n"
)
self.assertRaises(
StaticCompilationError,
lambda: compiler.compile_source('invalid syntax')
)
# Test non-ascii
NON_ASCII = """.external_link:first-child:before {
content: "Zobacz także:";
background: url(картинка.png);
}
"""
self.assertEqual(
compiler.compile_source(NON_ASCII),
NON_ASCII
)