File: test_misc.py

package info (click to toggle)
python-pyscss 1.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,080 kB
  • ctags: 1,962
  • sloc: python: 11,974; ansic: 1,493; makefile: 163; sh: 30
file content (96 lines) | stat: -rw-r--r-- 1,988 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""Tests for miscellaneous features that should maybe be broken out into their
own files, maybe.
"""

from scss import Scss


def test_super_selector():
    compiler = Scss(scss_opts=dict(style='expanded'))
    input = """\
foo, bar {
  a: b;
}
baz {
  c: d;
}
"""
    expected = """\
super foo, super bar {
  a: b;
}

super baz {
  c: d;
}
"""

    output = compiler.compile(input, super_selector='super')
    assert expected == output


def test_debug_info():
    # nb: debug info doesn't work if the source isn't a file
    compiler = Scss(scss_opts=dict(style='expanded', debug_info=True))
    compiler._scss_files = {}
    compiler._scss_files['input.css'] = """\
div {
    color: green;
}
table {
    color: red;
}
"""
    expected = """\
@media -sass-debug-info{filename{font-family:file\:\/\/input\.css}line{font-family:\\000031}}
div {
  color: green;
}

@media -sass-debug-info{filename{font-family:file\:\/\/input\.css}line{font-family:\\000034}}
table {
  color: red;
}
"""

    output = compiler.compile()
    assert expected == output


def test_live_errors():
    compiler = Scss(live_errors=True)
    output = compiler.compile("""$foo: unitless(one);""")
    assert "body:before" in output
    assert "TypeError: Expected" in output


def test_extend_across_files():
    compiler = Scss(scss_opts=dict(compress=0))
    compiler._scss_files = {}
    compiler._scss_files['first.css'] = '''
    @option style:legacy, short_colors:yes, reverse_colors:yes;
    .specialClass extends .basicClass {
        padding: 10px;
        font-size: 14px;
    }
    '''
    compiler._scss_files['second.css'] = '''
    @option style:legacy, short_colors:yes, reverse_colors:yes;
    .basicClass {
        padding: 20px;
        background-color: #FF0000;
    }
    '''
    actual = compiler.compile()
    expected = """\
.basicClass, .specialClass {
  padding: 20px;
  background-color: #FF0000;
}
.specialClass {
  padding: 10px;
  font-size: 14px;
}
"""

    assert expected == actual