本文整理汇总了Python中static_precompiler.compilers.SCSS类的典型用法代码示例。如果您正苦于以下问题:Python SCSS类的具体用法?Python SCSS怎么用?Python SCSS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SCSS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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",
]
)
示例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"
)
示例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"
)
示例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"
)
示例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"
)
示例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"),
[]
)
示例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"
)
示例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"),
[]
)
示例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")
示例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"))
示例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
)
示例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")
)
示例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
示例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"]
示例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") == []