當前位置: 首頁>>代碼示例>>Python>>正文


Python compilers.SCSS類代碼示例

本文整理匯總了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",
         ]
     )
開發者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


注:本文中的static_precompiler.compilers.SCSS類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。