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


Python compilers.LESS類代碼示例

本文整理匯總了Python中static_precompiler.compilers.LESS的典型用法代碼示例。如果您正苦於以下問題:Python LESS類的具體用法?Python LESS怎麽用?Python LESS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LESS類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_find_imports

    def test_find_imports(self):
        compiler = LESS()
        source = """
@import "foo.css";
@import " ";
@import "foo.less";
@import "@{VAR}.less";
@import (reference) "reference.less";
@import (inline) "inline.css";
@import (less) "less.less";
@import (css) "css.css";
@import (once) "once.less";
@import (multiple) "multiple.less";
@import "screen.less" screen;
@import url(url-import);
@import 'single-quotes.less';
@import "no-extension";
"""
        expected = sorted([
            "foo.less",
            "global-var.less",
            "reference.less",
            "inline.css",
            "less.less",
            "once.less",
            "multiple.less",
            "screen.less",
            "single-quotes.less",
            "no-extension",
        ])
        self.assertEqual(
            compiler.find_imports(source),
            expected
        )
開發者ID:Anber,項目名稱:django-static-precompiler,代碼行數:34,代碼來源:test_less.py

示例2: test_get_output_filename

 def test_get_output_filename(self):
     compiler = LESS()
     self.assertEqual(compiler.get_output_filename("dummy.less"), "dummy.css")
     self.assertEqual(
         compiler.get_output_filename("dummy.less.less"),
         "dummy.less.css"
     )
開發者ID:Onizuka89,項目名稱:django-static-precompiler,代碼行數:7,代碼來源:test_less.py

示例3: test_find_dependencies

    def test_find_dependencies(self):
        compiler = LESS()
        files = {
            "A.less": "@import 'B/C.less';",
            "B/C.less": "@import '../E';",
            "E.less": "p {color: red;}",
        }
        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.less"),
                ["B/C.less", "E.less"]
            )
            self.assertEqual(
                compiler.find_dependencies("B/C.less"),
                ["E.less"]
            )
            self.assertEqual(
                compiler.find_dependencies("E.less"),
                []
            )
開發者ID:Anber,項目名稱:django-static-precompiler,代碼行數:30,代碼來源:test_less.py

示例4: test_find_imports

    def test_find_imports(self):
        compiler = LESS()
        source = """
@import "foo.css", ;
@import " ";
@import "foo.less";
@import (less) "bar";
@import "foo";
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
@import "rounded-corners", "text-shadow";
"""
        expected = [
            "bar",
            "foo",
            "foo.less",
            "rounded-corners",
            "text-shadow",
        ]
        self.assertEqual(
            compiler.find_imports(source),
            expected
        )
開發者ID:Onizuka89,項目名稱:django-static-precompiler,代碼行數:25,代碼來源:test_less.py

示例5: test_postprocesss

def test_postprocesss(monkeypatch):
    compiler = LESS()

    convert_urls = call_recorder(lambda *args: "spam")

    monkeypatch.setattr("static_precompiler.compilers.less.convert_urls", convert_urls)

    assert compiler.postprocess("ham", "eggs") == "spam"
    assert convert_urls.calls == [call("ham", "eggs")]
開發者ID:and3rson,項目名稱:django-static-precompiler,代碼行數:9,代碼來源:test_less.py

示例6: test_compile_source

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
開發者ID:tgiachi,項目名稱:wi2m,代碼行數:15,代碼來源:test_less.py

示例7: test_compile_file

    def test_compile_file(self):
        compiler = LESS()

        self.assertEqual(
            compiler.compile_file("styles/test.less"),
            """p {
  font-size: 15px;
}
p a {
  color: #ff0000;
}
h1 {
  color: blue;
}
"""
        )
開發者ID:Anber,項目名稱:django-static-precompiler,代碼行數:16,代碼來源:test_less.py

示例8: test_find_dependencies

def test_find_dependencies(monkeypatch):
    compiler = LESS()
    files = {
        "A.less": "@import 'B/C.less';",
        "B/C.less": "@import '../E';",
        "E.less": "p {color: red;}",
    }
    monkeypatch.setattr("static_precompiler.compilers.less.LESS.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 path: path in existing_files)

    assert compiler.find_dependencies("A.less") == ["B/C.less", "E.less"]
    assert compiler.find_dependencies("B/C.less") == ["E.less"]
    assert compiler.find_dependencies("E.less") == []
開發者ID:and3rson,項目名稱:django-static-precompiler,代碼行數:20,代碼來源:test_less.py

示例9: test_locate_imported_file

    def test_locate_imported_file(self):
        compiler = LESS()
        with patch("os.path.exists") as mocked_os_path_exist:

            root = os.path.dirname(__file__)

            existing_files = set()
            for f in ("A/B.less", "D.less"):
                existing_files.add(os.path.join(root, "static", normalize_path(f)))

            mocked_os_path_exist.side_effect = lambda x: x in existing_files

            self.assertEqual(
                compiler.locate_imported_file("A", "B.less"),
                "A/B.less"
            )
            self.assertEqual(
                compiler.locate_imported_file("E", "../D"),
                "D.less"
            )
            self.assertEqual(
                compiler.locate_imported_file("E", "../A/B.less"),
                "A/B.less"
            )
            self.assertEqual(
                compiler.locate_imported_file("", "D.less"),
                "D.less"
            )
            self.assertRaises(
                StaticCompilationError,
                lambda: compiler.locate_imported_file("", "Z.less")
            )
開發者ID:Anber,項目名稱:django-static-precompiler,代碼行數:32,代碼來源:test_less.py

示例10: test_locate_imported_file

    def test_locate_imported_file(self):
        compiler = LESS()
        with patch("os.path.exists") as mocked_os_path_exist:

            existing_files = set()
            for f in ("A/B.less", "D.less"):
                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.less"),
                "A/B.less"
            )
            self.assertEqual(
                compiler.locate_imported_file("E", "../D"),
                "D.less"
            )
            self.assertEqual(
                compiler.locate_imported_file("E", "../A/B.less"),
                "A/B.less"
            )
            self.assertEqual(
                compiler.locate_imported_file("", "D.less"),
                "D.less"
            )
            self.assertRaises(
                StaticCompilationError,
                lambda: compiler.locate_imported_file("", "Z.less")
            )
開發者ID:bmcool,項目名稱:django-static-precompiler,代碼行數:30,代碼來源:test_less.py

示例11: test_compile_source

    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
        )
開發者ID:Anber,項目名稱:django-static-precompiler,代碼行數:23,代碼來源:test_less.py

示例12: test_locate_imported_file

def test_locate_imported_file(monkeypatch):
    compiler = LESS()

    root = os.path.dirname(__file__)

    existing_files = set()
    for f in ("A/B.less", "D.less"):
        existing_files.add(os.path.join(root, "static", normalize_path(f)))

    monkeypatch.setattr("os.path.exists", lambda path: path in existing_files)

    assert compiler.locate_imported_file("A", "B.less") == "A/B.less"
    assert compiler.locate_imported_file("E", "../D") == "D.less"
    assert compiler.locate_imported_file("E", "../A/B.less") == "A/B.less"
    assert compiler.locate_imported_file("", "D.less") == "D.less"

    with pytest.raises(StaticCompilationError):
        compiler.locate_imported_file("", "Z.less")
開發者ID:and3rson,項目名稱:django-static-precompiler,代碼行數:18,代碼來源:test_less.py

示例13: test_postprocesss

 def test_postprocesss(self):
     compiler = LESS()
     with patch("static_precompiler.compilers.less.convert_urls") as mocked_convert_urls:
         mocked_convert_urls.return_value = "spam"
         self.assertEqual(compiler.postprocess("ham", "eggs"), "spam")
         mocked_convert_urls.assert_called_with("ham", "eggs")
開發者ID:Anber,項目名稱:django-static-precompiler,代碼行數:6,代碼來源:test_less.py

示例14: test_is_supported

 def test_is_supported(self):
     compiler = LESS()
     self.assertEqual(compiler.is_supported("dummy"), False)
     self.assertEqual(compiler.is_supported("dummy.less"), True)
開發者ID:Onizuka89,項目名稱:django-static-precompiler,代碼行數:4,代碼來源:test_less.py

示例15: test_compile_file

def test_compile_file():
    compiler = LESS()

    assert compiler.compile_file("styles/test.less") == """p {
開發者ID:and3rson,項目名稱:django-static-precompiler,代碼行數:4,代碼來源:test_less.py


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