summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-08 18:56:48 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-08 18:56:48 -0700
commit2eb71a08fbea4143d3da1f00e911ac2ebfa0be4f (patch)
tree98429ef8ef7a5b5f027cce1f335f56cea7c60a7c
parent8abac3c5472798b996aae186565c2f4b9e97039f (diff)
downloadpyscss-2eb71a08fbea4143d3da1f00e911ac2ebfa0be4f.tar.gz
Fix the Compass headings() function.
-rw-r--r--scss/functions/compass/helpers.py8
-rw-r--r--scss/tests/functions/compass/test_helpers.py7
2 files changed, 9 insertions, 6 deletions
diff --git a/scss/functions/compass/helpers.py b/scss/functions/compass/helpers.py
index a12efb5..6a864ed 100644
--- a/scss/functions/compass/helpers.py
+++ b/scss/functions/compass/helpers.py
@@ -312,11 +312,11 @@ def headers(frm=None, to=None):
frm = 1
to = 6
else:
- frm = 1
try:
to = int(getattr(frm, 'value', frm))
except ValueError:
to = 6
+ frm = 1
else:
try:
frm = 1 if frm is None else int(getattr(frm, 'value', frm))
@@ -326,10 +326,8 @@ def headers(frm=None, to=None):
to = 6 if to is None else int(getattr(to, 'value', to))
except ValueError:
to = 6
- ret = ['h' + str(i) for i in range(frm, to + 1)]
- ret = dict(enumerate(ret))
- ret['_'] = ','
- return ret
+ ret = [StringValue('h' + str(i)) for i in range(frm, to + 1)]
+ return List(ret, use_comma=True)
@register('nest')
diff --git a/scss/tests/functions/compass/test_helpers.py b/scss/tests/functions/compass/test_helpers.py
index db095cc..0f801c1 100644
--- a/scss/tests/functions/compass/test_helpers.py
+++ b/scss/tests/functions/compass/test_helpers.py
@@ -78,7 +78,12 @@ def test_enumerate(calc):
assert calc('enumerate(foo, 4, 7)') == calc('foo-4, foo-5, foo-6, foo-7')
assert calc('enumerate("bar", 8, 10)') == calc('bar-8, bar-9, bar-10')
-# headers/headings
+def test_headings(calc):
+ assert calc('headings()') == calc('h1, h2, h3, h4, h5, h6')
+ assert calc('headings(all)') == calc('h1, h2, h3, h4, h5, h6')
+ assert calc('headings(2)') == calc('h1, h2')
+ assert calc('headings(2, 5)') == calc('h2, h3, h4, h5')
+
# nest