本文整理汇总了Python中static_precompiler.compilers.SCSS类的典型用法代码示例。如果您正苦于以下问题:Python SCSS类的具体用法?Python SCSS怎么用?Python SCSS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SCSS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_parse_import_string
def test_parse_import_string(self):
compiler = SCSS()
import_string = """"foo, bar" , "foo", url(bar,baz),
'bar,foo',bar screen, projection"""
self.assertEqual(
compiler.parse_import_string(import_string), [
"bar",
"bar,foo",
"foo",
"foo, bar",
]
)
import_string = """"foo,bar", url(bar,baz), 'bar,foo',bar screen, projection"""
self.assertEqual(
compiler.parse_import_string(import_string), [
"bar",
"bar,foo",
"foo,bar",
]
)
import_string = """"foo" screen"""
self.assertEqual(
compiler.parse_import_string(import_string), [
"foo",
]
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:26,代码来源:test_scss.py
示例2: test_compile_file
def test_compile_file():
compiler = SCSS()
assert (
fix_line_breaks(compiler.compile_file("styles/test.scss")) ==
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:7,代码来源:test_scss.py
示例3: test_compass
def test_compass():
compiler = SCSS(compass_enabled=True)
assert (
fix_line_breaks(compiler.compile_file("test-compass.scss")) ==
"p {\n background: url('/static/images/test.png'); }\n"
)
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:7,代码来源:test_scss.py
示例4: test_compass
def test_compass(self):
compiler = SCSS()
self.assertEqual(
fix_line_breaks(compiler.compile_file("test-compass.scss")),
"p {\n background: url('/static/images/test.png'); }\n"
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:7,代码来源:test_scss.py
示例5: test_compile_file
def test_compile_file(self):
compiler = SCSS()
self.assertEqual(
fix_line_breaks(compiler.compile_file("styles/test.scss")),
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:7,代码来源:test_scss.py
示例6: test_find_dependencies
def test_find_dependencies(self):
compiler = SCSS()
files = {
"A.scss": "@import 'B/C.scss';",
"B/C.scss": "@import '../E';",
"_E.scss": "p {color: red;}",
"compass-import.scss": '@import "compass"',
}
compiler.get_source = MagicMock(side_effect=lambda x: files[x])
root = os.path.dirname(__file__)
existing_files = set()
for f in files:
existing_files.add(os.path.join(root, "static", normalize_path(f)))
with patch("os.path.exists") as mocked_os_path_exist:
mocked_os_path_exist.side_effect = lambda x: x in existing_files
self.assertEqual(
compiler.find_dependencies("A.scss"),
["B/C.scss", "_E.scss"]
)
self.assertEqual(
compiler.find_dependencies("B/C.scss"),
["_E.scss"]
)
self.assertEqual(
compiler.find_dependencies("_E.scss"),
[]
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:31,代码来源:test_scss.py
示例7: test_get_output_filename
def test_get_output_filename(self):
compiler = SCSS()
self.assertEqual(compiler.get_output_filename("dummy.scss"), "dummy.css")
self.assertEqual(
compiler.get_output_filename("dummy.scss.scss"),
"dummy.scss.css"
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:7,代码来源:test_scss.py
示例8: test_find_dependencies
def test_find_dependencies(self):
compiler = SCSS()
files = {
"A.scss": "@import 'B/C.scss';",
"B/C.scss": "@import '../E';",
"_E.scss": "p {color: red;}",
}
compiler.get_source = MagicMock(side_effect=lambda x: files[x])
existing_files = set()
for f in files:
existing_files.add(os.path.join(STATIC_ROOT, f))
with patch("os.path.exists") as mocked_os_path_exist:
mocked_os_path_exist.side_effect = lambda x: x in existing_files
self.assertEqual(
compiler.find_dependencies("A.scss"),
["B/C.scss", "_E.scss"]
)
self.assertEqual(
compiler.find_dependencies("B/C.scss"),
["_E.scss"]
)
self.assertEqual(
compiler.find_dependencies("_E.scss"),
[]
)
开发者ID:bmcool,项目名称:django-static-precompiler,代码行数:28,代码来源:test_scss.py
示例9: test_compass_import
def test_compass_import():
compiler = SCSS(compass_enabled=True)
assert fix_line_breaks(compiler.compile_file("styles/test-compass-import.scss")) == ".round-corners {\n -moz-border-radius: 4px / 4px;\n -webkit-border-radius: 4px 4px;\n border-radius: 4px / 4px; }\n"
compiler = SCSS(compass_enabled=False)
with pytest.raises(StaticCompilationError):
compiler.compile_file("styles/test-compass-import.scss")
开发者ID:tgiachi,项目名称:wi2m,代码行数:8,代码来源:test_scss.py
示例10: test_compass_import
def test_compass_import(self):
compiler = SCSS()
with patch.object(compiler, "compass_enabled", return_value=True):
self.assertEqual(
fix_line_breaks(compiler.compile_file("styles/test-compass-import.scss")),
".round-corners {\n -webkit-border-radius: 4px 4px;\n -moz-border-radius: 4px / 4px;\n border-radius: 4px / 4px; }\n"
)
with patch.object(compiler, "compass_enabled", return_value=False):
self.assertRaises(StaticCompilationError, lambda: compiler.compile_file("styles/test-compass-import.scss"))
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:11,代码来源:test_scss.py
示例11: test_find_imports
def test_find_imports(self):
compiler = SCSS()
source = """
@import "foo.css", ;
@import " ";
@import "foo.scss";
@import "foo";
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
@import "rounded-corners",
"text-shadow";
@import "compass";
@import "compass.scss";
@import "compass/css3";
@import url(http://fonts.googleapis.com/css?family=Arvo:400,700,400italic,700italic);
@import url("http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,700,600,300");
@import "foo,bar", url(bar,baz), 'bar,foo';
"""
compiler.compass_enabled = MagicMock()
compiler.compass_enabled.return_value = False
expected = [
"bar,foo",
"compass",
"compass.scss",
"compass/css3",
"foo",
"foo,bar",
"foo.scss",
"rounded-corners",
"text-shadow",
]
self.assertEqual(
compiler.find_imports(source),
expected
)
compiler.compass_enabled.return_value = True
expected = [
"bar,foo",
"foo",
"foo,bar",
"foo.scss",
"rounded-corners",
"text-shadow",
]
self.assertEqual(
compiler.find_imports(source),
expected
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:53,代码来源:test_scss.py
示例12: test_locate_imported_file
def test_locate_imported_file(self):
compiler = SCSS()
with patch("os.path.exists") as mocked_os_path_exist:
existing_files = set()
for f in ("A/B.scss", "A/_C.scss", "D.scss"):
existing_files.add(os.path.join(STATIC_ROOT, f))
mocked_os_path_exist.side_effect = lambda x: x in existing_files
self.assertEqual(
compiler.locate_imported_file("A", "B.scss"),
"A/B.scss"
)
self.assertEqual(
compiler.locate_imported_file("A", "C"),
"A/_C.scss"
)
self.assertEqual(
compiler.locate_imported_file("E", "../D"),
"D.scss"
)
self.assertEqual(
compiler.locate_imported_file("E", "../A/B.scss"),
"A/B.scss"
)
self.assertEqual(
compiler.locate_imported_file("", "D.scss"),
"D.scss"
)
self.assertRaises(
StaticCompilationError,
lambda: compiler.locate_imported_file("", "Z.scss")
)
开发者ID:bmcool,项目名称:django-static-precompiler,代码行数:34,代码来源:test_scss.py
示例13: test_find_imports
def test_find_imports():
source = """
@import "foo.css", ;
@import " ";
@import "foo.scss";
@import "foo";
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
@import "rounded-corners",
"text-shadow";
@import "compass";
@import "compass.scss";
@import "compass/css3";
@import url(http://fonts.googleapis.com/css?family=Arvo:400,700,400italic,700italic);
@import url("http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,700,600,300");
@import "foo,bar", url(bar,baz), 'bar,foo';
"""
expected = [
"bar,foo",
"compass",
"compass.scss",
"compass/css3",
"foo",
"foo,bar",
"foo.scss",
"rounded-corners",
"text-shadow",
]
compiler = SCSS(compass_enabled=False)
assert compiler.find_imports(source) == expected
compiler = SCSS(compass_enabled=True)
expected = [
"bar,foo",
"foo",
"foo,bar",
"foo.scss",
"rounded-corners",
"text-shadow",
]
assert compiler.find_imports(source) == expected
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:44,代码来源:test_scss.py
示例14: test_parse_import_string
def test_parse_import_string():
compiler = SCSS()
import_string = """"foo, bar" , "foo", url(bar,baz),
'bar,foo',bar screen, projection"""
assert compiler.parse_import_string(import_string) == [
"bar",
"bar,foo",
"foo",
"foo, bar",
]
import_string = """"foo,bar", url(bar,baz), 'bar,foo',bar screen, projection"""
assert compiler.parse_import_string(import_string) == [
"bar",
"bar,foo",
"foo,bar",
]
import_string = """"foo" screen"""
assert compiler.parse_import_string(import_string) == ["foo"]
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:20,代码来源:test_scss.py
示例15: test_find_dependencies
def test_find_dependencies(monkeypatch):
compiler = SCSS()
files = {
"A.scss": "@import 'B/C.scss';",
"B/C.scss": "@import '../E';",
"_E.scss": "p {color: red;}",
"compass-import.scss": '@import "compass"',
}
monkeypatch.setattr("static_precompiler.compilers.scss.SCSS.get_source", lambda self, x: files[x])
root = os.path.dirname(__file__)
existing_files = set()
for f in files:
existing_files.add(os.path.join(root, "static", normalize_path(f)))
monkeypatch.setattr("os.path.exists", lambda x: x in existing_files)
assert compiler.find_dependencies("A.scss") == ["B/C.scss", "_E.scss"]
assert compiler.find_dependencies("B/C.scss") == ["_E.scss"]
assert compiler.find_dependencies("_E.scss") == []
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:21,代码来源:test_scss.py
示例16: test_locate_imported_file
def test_locate_imported_file(monkeypatch):
compiler = SCSS()
root = os.path.dirname(__file__)
existing_files = set()
for f in ("A/B.scss", "A/_C.scss", "A/S.sass", "D.scss"):
existing_files.add(os.path.join(root, "static", normalize_path(f)))
monkeypatch.setattr("os.path.exists", lambda x: x in existing_files)
assert compiler.locate_imported_file("A", "B.scss") == "A/B.scss"
assert compiler.locate_imported_file("A", "C") == "A/_C.scss"
assert compiler.locate_imported_file("E", "../D") == "D.scss"
assert compiler.locate_imported_file("E", "../A/B.scss") == "A/B.scss"
assert compiler.locate_imported_file("", "D.scss") == "D.scss"
assert compiler.locate_imported_file("A", "S.sass") == "A/S.sass"
assert compiler.locate_imported_file("A", "S") == "A/S.sass"
with pytest.raises(StaticCompilationError):
compiler.locate_imported_file("", "Z.scss")
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:21,代码来源:test_scss.py
示例17: test_compile_source
def test_compile_source(self):
compiler = SCSS()
self.assertEqual(
fix_line_breaks(compiler.compile_source("p {font-size: 15px; a {color: red;}}")),
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
self.assertRaises(
StaticCompilationError,
lambda: compiler.compile_source('invalid syntax')
)
# Test non-ascii
NON_ASCII = """@charset "UTF-8";
.external_link:first-child:before {
content: "Zobacz także:";
background: url(картинка.png); }
"""
self.assertEqual(
fix_line_breaks(compiler.compile_source(NON_ASCII)),
NON_ASCII
)
开发者ID:datanordic,项目名称:django-static-precompiler,代码行数:23,代码来源:test_scss.py
示例18: test_find_imports
def test_find_imports(self):
compiler = SCSS()
source = """
@import "foo.css", ;
@import " ";
@import "foo.scss";
@import "foo";
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
@import "rounded-corners", "text-shadow";
"""
expected = [
"foo",
"foo.scss",
"rounded-corners",
"text-shadow",
]
self.assertEqual(
compiler.find_imports(source),
expected
)
开发者ID:bmcool,项目名称:django-static-precompiler,代码行数:23,代码来源:test_scss.py
示例19: test_postprocesss
def test_postprocesss(monkeypatch):
compiler = SCSS()
convert_urls = call_recorder(lambda *args: "spam")
monkeypatch.setattr("static_precompiler.compilers.scss.convert_urls", convert_urls)
assert compiler.postprocess("ham", "eggs") == "spam"
assert convert_urls.calls == [call("ham", "eggs")]
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:6,代码来源:test_scss.py
示例20: test_compile_source
def test_compile_source():
compiler = SCSS(executable="scss")
assert (
fix_line_breaks(compiler.compile_source("p {font-size: 15px; a {color: red;}}")) ==
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
compiler = SCSS(executable="sass")
assert (
fix_line_breaks(compiler.compile_source("p {font-size: 15px; a {color: red;}}")) ==
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
with pytest.raises(StaticCompilationError):
compiler.compile_source('invalid syntax')
with pytest.raises(StaticCompilationError):
compiler.compile_source('invalid syntax')
# Test non-ascii
NON_ASCII = """@charset "UTF-8";
.external_link:first-child:before {
content: "Zobacz także:";
background: url(картинка.png); }
"""
assert fix_line_breaks(compiler.compile_source(NON_ASCII)) == NON_ASCII
compiler = SASS(executable="sass")
assert (
fix_line_breaks(compiler.compile_source("p\n font-size: 15px\n a\n color: red")) ==
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
compiler = SASS(executable="scss")
assert (
fix_line_breaks(compiler.compile_source("p\n font-size: 15px\n a\n color: red")) ==
"p {\n font-size: 15px; }\n p a {\n color: red; }\n"
)
开发者ID:and3rson,项目名称:django-static-precompiler,代码行数:37,代码来源:test_scss.py
注:本文中的static_precompiler.compilers.SCSS类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论