Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Fix TypeError when preferred_aliases provided as list of unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
muusik committed Dec 17, 2016
1 parent 00b8a77 commit 93ff87e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion confusable_homoglyphs/confusables.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def is_confusable(string, greedy=False, preferred_aliases=[]):
otherwise.
:rtype: bool or list
"""
preferred_aliases = list(map(str.upper, preferred_aliases))
preferred_aliases = [a.upper() for a in preferred_aliases]
outputs = []
checked = set()
for char in string:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_confusables.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def test_is_confusable(self):
confusable = confusables.is_confusable(u'paρa', preferred_aliases=['greek'])[0]['character']
self.assertEqual(confusable, 'p')

try:
confusables.is_confusable('', preferred_aliases=[u'latin'])
except TypeError:
self.fail('TypeError when preferred_aliases provided as unicode')

def test_dangerous(self):
self.assertTrue(confusables.is_dangerous(looks_good))
self.assertTrue(confusables.is_dangerous(u' ρττ a'))
Expand All @@ -62,5 +67,6 @@ def test_dangerous(self):
self.assertFalse(confusables.is_dangerous(u' ρτ.τ'))
self.assertFalse(confusables.is_dangerous(u'ρτ.τ'))


if __name__ == '__main__':
unittest.main()

0 comments on commit 93ff87e

Please sign in to comment.