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

// Get in line!
@var: white;'''), '')
    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;
}''')
    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 }
''')
Exemple #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;
}''')
Exemple #5
0
    def test_units(self):
        self.assertEqual(
            compile(u'''@var: 1px + 5;

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

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

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

#page {
  @var: white;
  #header {
    color: @var; // white
  }
}'''), u'''#page #header { color: white; }''')
Exemple #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'''''')
    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; }''')
Exemple #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; }''')
    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;
}''')
Exemple #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;
}''')
    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%;
}''')
Exemple #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%;
}''')
 def test_parse(self):
     self.assertEqual(compile(u'div { width: 1 + 1 }'), u'div { width: 2; }')
    def test_comments(self):
        self.assertEqual(compile(u'''/* One hell of a comment */
@var: red;

// Get in line!
@var: white;'''), '')
Exemple #18
0
 def test_invoke2(self):
     self.assertEqual(compile(u'.post { color: blue }'),
                      u'.post { color: blue; }')
Exemple #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; }')
Exemple #20
0
 def test_parse(self):
     self.assertEqual(compile(u'div { width: 1 + 1 }'),
                      u'div { width: 2; }')
Exemple #21
0
 def test_invoke1(self):
     self.assertEqual(compile(u'a { color: blue }'), u'a { color: blue; }')
 def test_invoke1(self):
     self.assertEqual(compile(u'a { color: blue }'), u'a { color: blue; }')
 def test_invoke2(self):
     self.assertEqual(compile(u'.post { color: blue }'),
                      u'.post { color: blue; }')
    def test_variables(self):
        self.assertEqual(compile(u'''@nice-blue: #5B83AD;
@light-blue: @nice-blue + #111;

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

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