mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
Merge pull request #696 from ayberk/master
Fixed #453 and added test cases
This commit is contained in:
commit
eee2213099
2 changed files with 14 additions and 2 deletions
|
|
@ -1121,9 +1121,13 @@ class DefaultTemplateFunctions(object):
|
|||
otherwise, emit ``falseval`` (if provided).
|
||||
"""
|
||||
try:
|
||||
condition = _int_arg(condition)
|
||||
int_condition = _int_arg(condition)
|
||||
except ValueError:
|
||||
condition = condition.strip()
|
||||
if condition.lower() == "false":
|
||||
return falseval
|
||||
else:
|
||||
condition = int_condition
|
||||
|
||||
if condition:
|
||||
return trueval
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -496,6 +496,10 @@ class DestinationFunctionTest(_common.TestCase, PathFormattingMixin):
|
|||
self._setf(u'x%if{,foo}')
|
||||
self._assert_dest('/base/x')
|
||||
|
||||
def test_if_false_value(self):
|
||||
self._setf(u'x%if{false,foo}')
|
||||
self._assert_dest('/base/x')
|
||||
|
||||
def test_if_true(self):
|
||||
self._setf(u'%if{bar,foo}')
|
||||
self._assert_dest('/base/foo')
|
||||
|
|
@ -504,6 +508,10 @@ class DestinationFunctionTest(_common.TestCase, PathFormattingMixin):
|
|||
self._setf(u'%if{,foo,baz}')
|
||||
self._assert_dest('/base/baz')
|
||||
|
||||
def test_if_else_false_value(self):
|
||||
self._setf(u'%if{false,foo,baz}')
|
||||
self._assert_dest('/base/baz')
|
||||
|
||||
def test_if_int_value(self):
|
||||
self._setf(u'%if{0,foo,baz}')
|
||||
self._assert_dest('/base/baz')
|
||||
|
|
|
|||
Loading…
Reference in a new issue