From 1bed75d814509f7816c92de665cf6966766c0883 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Tue, 4 Jun 2019 16:30:32 +0200 Subject: ContactsCompletion: use db.utils.formataddr email.utils.formataddr does more encoding than we need at this point - headers will be encoded when they get inserted anyway. Use db.utils.formataddr instead. Fixes #1378 Note that some tests need to be (and are) changed: The expectation of the old tests was to get a completely escaped result. Also, add an umlaut test. --- tests/test_completion.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_completion.py b/tests/test_completion.py index 79f07e1b..cf94d0eb 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -20,6 +20,7 @@ def _mock_lookup(query): abook = [ ("", "no-real-name@example.com"), ("foo", "foo@example.com"), + ("Ümläut", "umlaut@example.com"), ("comma, person", "comma@example.com"), ("single 'quote' person", "squote@example.com"), ('double "quote" person', "dquote@example.com"), @@ -65,6 +66,11 @@ class AbooksCompleterTest(unittest.TestCase): expected = [("foo ", 21)] self.assertListEqual(actual, expected) + def test_simple_address_with_umlaut_real_name(self): + actual = self.__class__.example_abook_completer.complete("umlaut", 6) + expected = [("Ümläut ", 27)] + self.assertListEqual(actual, expected) + def test_real_name_with_comma(self): actual = self.__class__.example_abook_completer.complete("comma", 5) expected = [('"comma, person" ', 35)] @@ -79,13 +85,13 @@ class AbooksCompleterTest(unittest.TestCase): actual = self.__class__.example_abook_completer.complete("dquote", 6) expected = [("", 0)] expected = [ - (r""""double \"quote\" person" """, 46)] + (r"""double "quote" person """, 42)] self._assert_only_one_list_entry(actual, expected) def test_real_name_with_quotes_and_comma(self): actual = self.__class__.example_abook_completer.complete("all", 3) - expected = [(r""""all 'fanzy' \"stuff\" at, once" """, - 50)] + expected = [(r""""all 'fanzy' "stuff" at, once" """, + 48)] self._assert_only_one_list_entry(actual, expected) -- cgit v1.2.3