forked from sass/libsass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsasstests.py
More file actions
91 lines (70 loc) · 2.27 KB
/
sasstests.py
File metadata and controls
91 lines (70 loc) · 2.27 KB
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
from __future__ import with_statement
from attest import assert_hook
import re
from attest import Tests, raises
import sass
suite = Tests()
@suite.test
def version():
assert re.match(r'^\d+\.\d+\.\d+$', sass.__version__)
@suite.test
def compile_required_arguments():
with raises(TypeError):
sass.compile()
@suite.test
def compile_takes_only_keywords():
with raises(TypeError):
sass.compile('a { color: blue; }')
@suite.test
def compile_exclusive_arguments():
with raises(TypeError):
sass.compile(string='a { color: blue; }',
filename='test/a.sass')
with raises(TypeError):
sass.compile(string='a { color: blue; }',
dirname='test/')
with raises(TypeError):
sass.compile(filename='test/a.sass',
dirname='test/')
@suite.test
def compile_invalid_output_style():
with raises(TypeError):
sass.compile(string='a { color: blue; }', output_style=['compact'])
with raises(TypeError):
sass.compile(string='a { color: blue; }', output_style=123j)
with raises(ValueError):
sass.compile(string='a { color: blue; }', output_style='invalid')
@suite.test
def compile_invalid_image_path():
with raises(TypeError):
sass.compile(string='a { color: blue; }', image_path=[])
with raises(TypeError):
sass.compile(string='a { color: blue; }', image_path=123)
@suite.test
def compile_string():
actual = sass.compile(string='a { b { color: blue; } }')
assert actual == 'a b {\n color: blue; }\n'
with raises(sass.CompileError):
sass.compile(string='a { b { color: blue; }')
# sass.CompileError should be a subtype of ValueError
with raises(ValueError):
sass.compile(string='a { b { color: blue; }')
with raises(TypeError):
sass.compile(string=1234)
with raises(TypeError):
sass.compile(string=[])
@suite.test
def compile_filename():
actual = sass.compile(filename='test/a.sass')
assert actual == '''\
body {
background-color: green; }
body a {
color: blue; }
'''
with raises(IOError):
sass.compile(filename='test/not-exist.sass')
with raises(TypeError):
sass.compile(filename=1234)
with raises(TypeError):
sass.compile(filename=[])