From 2eb71a08fbea4143d3da1f00e911ac2ebfa0be4f Mon Sep 17 00:00:00 2001 From: "Eevee (Alex Munroe)" Date: Thu, 8 Aug 2013 18:56:48 -0700 Subject: Fix the Compass headings() function. --- scss/functions/compass/helpers.py | 8 +++----- scss/tests/functions/compass/test_helpers.py | 7 ++++++- 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 -- cgit v1.2.1