コード例 #1
0
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")
コード例 #2
0
ファイル: test_scss.py プロジェクト: tgiachi/wi2m
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"
コード例 #3
0
    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)
コード例 #4
0
    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
        )