Example #1
0
    def test_comments(self):
        self.assertEqual(
            compile(u'''/* One hell of a comment */
@var: red;

// Get in line!
@var: white;'''), '')
Example #2
0
    def test_mixin(self):
        self.assertEqual(compile(u'''.bordered {
  border-top: dotted 1px black;
  border-bottom: solid 2px black;
}

#menu a {
  color: #111;
  .bordered;
}

.post a {
  color: red;
  .bordered;
}'''), '''#menu a {
  border-bottom: solid 2px black;
  border-top: dotted 1px black;
  color: #111;
}

.bordered {
  border-bottom: solid 2px black;
  border-top: dotted 1px black;
}

.post a {
  border-bottom: solid 2px black;
  border-top: dotted 1px black;
  color: red;
}''')
Example #3
0
    def test_namespaces(self):
        self.assertEqual(compile(u'''
#bundle {
  .button () {
    display: block;
    border: 1px solid black;
    background-color: grey;
    &:hover { background-color: white }
  }
  .tab { }
  .citation { }
}

#header a {
  color: orange;
  #bundle > .button;
}
'''), u'''
#header a {
  color: orange;  
  display: block;
  border: 1px solid black;
  background-color: grey;
}
#header a:hover { background-color: white }
''')
Example #4
0
    def test_mixin(self):
        self.assertEqual(
            compile(u'''.bordered {
  border-top: dotted 1px black;
  border-bottom: solid 2px black;
}

#menu a {
  color: #111;
  .bordered;
}

.post a {
  color: red;
  .bordered;
}'''), '''#menu a {
  border-bottom: solid 2px black;
  border-top: dotted 1px black;
  color: #111;
}

.bordered {
  border-bottom: solid 2px black;
  border-top: dotted 1px black;
}

.post a {
  border-bottom: solid 2px black;
  border-top: dotted 1px black;
  color: red;
}''')
Example #5
0
    def test_units(self):
        self.assertEqual(
            compile(u'''@var: 1px + 5;

* {
    width: @var;
}'''), u'* { width: 6px; }')
Example #6
0
    def test_scope(self):
        self.assertEqual(compile(u'''@var: red;

#page {
  @var: white;
  #header {
    color: @var; // white
  }
}'''), u'''#page #header { color: white; }''')
Example #7
0
    def test_camelCase_variables(self):
        self.assertEqual(compile(u'''
@black:                 #000;
@grayDarker:            #222;
@grayDark:              #333;

.hello { color:@grayDark }
'''),
        u'.hello { color: #333; }'
        )
Example #8
0
    def test_scope(self):
        self.assertEqual(
            compile(u'''@var: red;

#page {
  @var: white;
  #header {
    color: @var; // white
  }
}'''), u'''#page #header { color: white; }''')
Example #9
0
    def test_namespaces(self):
        self.assertEqual(
            compile(u'''#bundle {
  .button {
    display: block;
    border: 1px solid black;
    background-color: grey;
    :hover { background-color: white }
  }
  .tab { }
  .citation { }
}

#header a {
  color: orange;
  #bundle > .button;
}'''), u'''''')
Example #10
0
    def test_nested_rules(self):
        self.assertEqual(compile(u'''#header {
  color: black;

  .navigation {
    font-size: 12px;
  }
  .logo {
    width: 300px;
    :hover { text-decoration: none }
  }
}'''), u'''#header { color: black; }

#header .logo { width: 300px; }

#header .logo:hover { text-decoration: none; }

#header .navigation { font-size: 12px; }''')
Example #11
0
    def test_nested_rules(self):
        self.assertEqual(
            compile(u'''#header {
  color: black;

  .navigation {
    font-size: 12px;
  }
  .logo {
    width: 300px;
    :hover { text-decoration: none }
  }
}'''), u'''#header { color: black; }

#header .logo { width: 300px; }

#header .logo:hover { text-decoration: none; }

#header .navigation { font-size: 12px; }''')
Example #12
0
    def test_accessors(self):
        self.assertEqual(compile(u'''#defaults {
  @width: 960px;
  @color: black;
}

.article { color: #294366; }

.comment {
  width: #defaults[@width];
  color: .article['color'];
}'''), u'''.article {
  color: #294366;
}

.comment {
  color: #294366;
  width: 960px;
}''')
Example #13
0
    def test_accessors(self):
        self.assertEqual(
            compile(u'''#defaults {
  @width: 960px;
  @color: black;
}

.article { color: #294366; }

.comment {
  width: #defaults[@width];
  color: .article['color'];
}'''), u'''.article {
  color: #294366;
}

.comment {
  color: #294366;
  width: 960px;
}''')
Example #14
0
    def test_operations(self):
        self.assertEqual(compile(u'''@base: 5%;
@filler: @base * 2;
@other: @base + @filler;
@base-color: #222;

* {
  padding: @base;
  width: @filler;
  margin: @other;

  color: #888 / 4;
  background-color: @base-color + #111;
  height: 100% / 2 + @filler;
}'''), u'''* {
  background-color: #333;
  color: #222;
  height: 60%;
  margin: 15%;
  padding: 5%;
  width: 10%;
}''')
Example #15
0
    def test_operations(self):
        self.assertEqual(
            compile(u'''@base: 5%;
@filler: @base * 2;
@other: @base + @filler;
@base-color: #222;

* {
  padding: @base;
  width: @filler;
  margin: @other;

  color: #888 / 4;
  background-color: @base-color + #111;
  height: 100% / 2 + @filler;
}'''), u'''* {
  background-color: #333;
  color: #222;
  height: 60%;
  margin: 15%;
  padding: 5%;
  width: 10%;
}''')
Example #16
0
 def test_parse(self):
     self.assertEqual(compile(u'div { width: 1 + 1 }'), u'div { width: 2; }')
Example #17
0
    def test_comments(self):
        self.assertEqual(compile(u'''/* One hell of a comment */
@var: red;

// Get in line!
@var: white;'''), '')
Example #18
0
 def test_invoke2(self):
     self.assertEqual(compile(u'.post { color: blue }'),
                      u'.post { color: blue; }')
Example #19
0
    def test_variables(self):
        self.assertEqual(
            compile(u'''@nice-blue: #5B83AD;
@light-blue: @nice-blue + #111;

#header { color: @light-blue; }'''), u'#header { color: #6c94be; }')
Example #20
0
 def test_parse(self):
     self.assertEqual(compile(u'div { width: 1 + 1 }'),
                      u'div { width: 2; }')
Example #21
0
 def test_invoke1(self):
     self.assertEqual(compile(u'a { color: blue }'), u'a { color: blue; }')
Example #22
0
 def test_invoke1(self):
     self.assertEqual(compile(u'a { color: blue }'), u'a { color: blue; }')
Example #23
0
 def test_invoke2(self):
     self.assertEqual(compile(u'.post { color: blue }'),
                      u'.post { color: blue; }')
Example #24
0
    def test_variables(self):
        self.assertEqual(compile(u'''@nice-blue: #5B83AD;
@light-blue: @nice-blue + #111;

#header { color: @light-blue; }'''), u'#header { color: #6c94be; }')
Example #25
0
 def test_ie_compatible_asterisk(self):
     # Allow bullshit IE6/7 hacks
     self.assertEqual(compile(u'''p { *width: 350px; }'''), 
       u"""p { *width: 350px; }"""
     )
Example #26
0
    def test_units(self):
        self.assertEqual(compile(u'''@var: 1px + 5;

* {
    width: @var;
}'''), u'* { width: 6px; }')