mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Crash fix: lookup with empty prefixes.
This commit is contained in:
parent
27364e1fbc
commit
cf72e1db36
2 changed files with 10 additions and 1 deletions
|
@ -296,7 +296,11 @@ class PokedexLookup(object):
|
|||
name = name.strip()
|
||||
|
||||
prefixes = prefix_chunk.split(',')
|
||||
user_valid_types = [_.strip() for _ in prefixes]
|
||||
user_valid_types = []
|
||||
for prefix in prefixes:
|
||||
prefix = prefix.strip()
|
||||
if prefix:
|
||||
user_valid_types.append(prefix)
|
||||
|
||||
# Merge the valid types together. Only types that appear in BOTH lists
|
||||
# may be used.
|
||||
|
|
|
@ -146,3 +146,8 @@ def test_random_lookup():
|
|||
assert_equal(len(results), 1, u'Constrained random returns one result')
|
||||
assert_equal(results[0].object.__tablename__, table_name,
|
||||
u'Constrained random returns result from the right table')
|
||||
|
||||
def test_crash_empty_prefix():
|
||||
"""Searching for ':foo' used to crash, augh!"""
|
||||
results = lookup.lookup(u'Eevee')
|
||||
assert_equal(results[0].object.name, u'Eevee', u'Empty prefix dun crash')
|
||||
|
|
Loading…
Reference in a new issue