Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
KFoxder committed Nov 9, 2022
1 parent 3d55612 commit 8cb0fed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions autocompleter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def replace_all(string, replace=[], with_this=""):
return string


def get_normalized_term(term, replaced_chars=None):
def get_normalized_term(term, replaced_chars=[]):
"""
Convert the term into a basic form that's easier to search.
1) Force convert from text to unicode if necessary
Expand All @@ -33,11 +33,10 @@ def get_normalized_term(term, replaced_chars=None):
term = unicodedata.normalize("NFKD", term).encode("ASCII", "ignore").decode("utf-8")
term = term.replace("&", "and")
term = term.strip()
if replaced_chars is not None and isinstance(replaced_chars, list):
if replaced_chars != []:
term = replace_all(term, replace=replaced_chars, with_this=" ")
term = re.sub(settings.CHARACTER_FILTER, "", term)
term = re.sub(r"[\s]+", " ", term)
term = term.strip()
return term


Expand Down
2 changes: 1 addition & 1 deletion test_project/test_app/tests/test_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class IndicatorMatchTestCase(AutocompleterTestCase):
fixtures = ["indicator_test_data_small.json"]

def setUp(self):
super(IndicatorMatchTestCase, self).setUp()
super().setUp()
self.autocomp = Autocompleter("indicator")
self.autocomp.store_all()

Expand Down
4 changes: 2 additions & 2 deletions test_project/test_app/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ def test_replace_characters(self):
"us and china", get_normalized_term("US & [CHiNA]", replaced_chars=[])
)
self.assertEqual(
"percent change",
" percent change",
get_normalized_term("Non Percent Change", replaced_chars=["non"]),
)
self.assertEqual(
"cent change",
" cent change",
get_normalized_term("Non Percent Change", replaced_chars=["non", "per"]),
)

0 comments on commit 8cb0fed

Please sign in to comment.