Skip to content

Commit

Permalink
Merge pull request #34 from mamico/issue30
Browse files Browse the repository at this point in the history
fix is_iter implementation. see #30
  • Loading branch information
delijati authored Aug 29, 2016
2 parents ac58fe5 + df1fc8e commit 215afb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0.10.2 (unreleased)
-------------------

- Nothing changed yet.
- fix is_iter implementation #30 (mamico)


0.10.1 (2016-06-15)
Expand Down
4 changes: 3 additions & 1 deletion scorched/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
import numbers
import operator
import re

import scorched.strings
import scorched.exc
import scorched.dates

from functools import reduce
from scorched.compat import str
from scorched.compat import basestring
from scorched.compat import python_2_unicode_compatible


PARSERS = ("edismax", "dismax")


def is_iter(val):
return isinstance(val, (tuple, list))
return not isinstance(val, basestring) and isinstance(val, collections.Iterable)


class LuceneQuery(object):
Expand Down
11 changes: 10 additions & 1 deletion scorched/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
PostingsHighlightOptions, FacetPivotOptions,
RequestHandlerOption, DebugOptions,
params_from_dict, FacetRangeOptions,
TermVectorOptions, StatOptions)
TermVectorOptions, StatOptions,
is_iter)
from scorched.strings import WildcardString
from nose.tools import assert_equal

Expand Down Expand Up @@ -627,3 +628,11 @@ def test_url_encode_data():
def test_mlt_query_options():
for (fields, query_fields, kwargs, output) in mlt_query_options_data:
yield check_mlt_query_options, fields, query_fields, kwargs, output


def test_is_iter():
assert is_iter("abc") == False
assert is_iter(1) == False
assert is_iter([1, 2]) == True
assert is_iter((1, 2)) == True
assert is_iter(set([1, 2])) == True

0 comments on commit 215afb2

Please sign in to comment.