Ejemplo n.º 1
0
 def test_less_errors(self):
     try:
         dukpy.less_compile('@import "files/missing.less";')
     except LessCompilerError as e:
         assert "files/missing.less' wasn't found." in str(e)
     else:
         assert False, 'Exception not raised'
Ejemplo n.º 2
0
    def test_less(self):
        ans = dukpy.less_compile(
            '''
@import "files/colors.less";

.box-shadow(@style, @c) when (iscolor(@c)) {
  -webkit-box-shadow: @style @c;
  box-shadow:         @style @c;
}
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
  .box-shadow(@style, rgba(0, 0, 0, @alpha));
}
.box {
  color: saturate(@green, 5%);
  border-color: lighten(@green, 30%);
  div { .box-shadow(0 0 5px, 30%) }
}
''',
            options={'paths': [os.path.dirname(__file__)]})

        expected = '''box {
  color: #7cb029;
  border-color: #c2e191;
}
.box div {
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}'''

        assert expected in ans, report_diff(expected, ans)
Ejemplo n.º 3
0
    def input(self, _in, out, **kw):
        options = {'paths': []}
        if self.less_includes:
            options['paths'].extend(self.less_includes)
        if 'source_path' in kw:
            options['paths'].append(os.path.dirname(kw['source_path']))

        src = dukpy.less_compile(_in.read(), options=options)
        out.write(src)
Ejemplo n.º 4
0
    def input(self, _in, out, **kw):
        options = {'paths': []}
        if self.less_includes:
            options['paths'].extend(self.less_includes)
        if 'source_path' in kw:
            options['paths'].append(os.path.dirname(kw['source_path']))

        src = dukpy.less_compile(_in.read(), options=options)
        out.write(src)
Ejemplo n.º 5
0
 def test_less_errors(self):
     with self.assertRaises(LessCompilerError) as err:
         dukpy.less_compile('@import "files/missing.less";')
     assert "files/missing.less' wasn't found." in str(err.exception)