summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-13 14:08:42 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-13 14:08:42 -0700
commite1a4c457d457f4a553d83737ad9dd5b3a597d035 (patch)
treeae48cb2856006f93588c2271c57ec8335cff7581
parent863d8a0acb806f32e0db52153b1a51045880e043 (diff)
downloadpyscss-e1a4c457d457f4a553d83737ad9dd5b3a597d035.tar.gz
Fix unquote() to work on lists.
-rw-r--r--scss/functions/core.py14
-rw-r--r--scss/tests/functions/test_core.py20
2 files changed, 27 insertions, 7 deletions
diff --git a/scss/functions/core.py b/scss/functions/core.py
index 5f36be3..b4a3a19 100644
--- a/scss/functions/core.py
+++ b/scss/functions/core.py
@@ -396,12 +396,22 @@ def change_color(color, saturation=None, lightness=None, red=None, green=None, b
@register('escape', 1)
@register('unquote')
def unquote(*args):
- return StringValue(' '.join([StringValue(s).value for s in args]))
+ arg = List.from_maybe_starargs(args).maybe()
+
+ if isinstance(arg, StringValue):
+ return StringValue(arg.value, quotes=None)
+ else:
+ return StringValue(arg.render(), quotes=None)
@register('quote')
def quote(*args):
- return QuotedStringValue(' '.join([StringValue(s).value for s in args]))
+ arg = List.from_maybe_starargs(args).maybe()
+
+ if isinstance(arg, StringValue):
+ return StringValue(arg.value, quotes='"')
+ else:
+ return StringValue(arg.render(), quotes='"')
# ------------------------------------------------------------------------------
diff --git a/scss/tests/functions/test_core.py b/scss/tests/functions/test_core.py
index d02a479..c36250c 100644
--- a/scss/tests/functions/test_core.py
+++ b/scss/tests/functions/test_core.py
@@ -8,7 +8,7 @@ from __future__ import division
from scss.expression import Calculator
from scss.functions.core import CORE_LIBRARY
from scss.rule import Namespace
-from scss.types import ColorValue, NumberValue
+from scss.types import ColorValue, NumberValue, String
import pytest
xfail = pytest.mark.xfail
@@ -200,13 +200,23 @@ def test_ie_hex_str(calc):
def test_unquote(calc):
# Examples from the Ruby docs
- assert calc('unquote("foo")') == calc('foo')
- assert calc('unquote(foo)') == calc('foo')
+ ret = calc('unquote("foo")')
+ assert ret == String('foo')
+ assert ret.quotes is None
+ ret = calc('unquote(foo)')
+ assert ret == String('foo')
+ assert ret.quotes is None
+
+ assert calc('unquote((one, two, three))') == String('one, two, three')
def test_quote(calc):
# Examples from the Ruby docs
- assert calc('quote("foo")') == calc('"foo"')
- assert calc('quote(foo)') == calc('"foo"')
+ ret = calc('quote("foo")')
+ assert ret == String('foo')
+ assert ret.quotes == '"'
+ ret = calc('quote(foo)')
+ assert ret == String('foo')
+ assert ret.quotes == '"'
# ------------------------------------------------------------------------------