summaryrefslogtreecommitdiff
path: root/tests/db
diff options
context:
space:
mode:
authorLucas Hoffmann <lucc@posteo.de>2019-11-04 08:00:10 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2019-11-06 10:54:00 +0000
commit414ca6c4b57752d139598e95e06009c55ff4543c (patch)
treea77d60aaf05f2c75224df95f7481f7328e414e7a /tests/db
parentbbb96525c08f0c6ee9fc93e0dd0ccb3abfd1dca8 (diff)
Remove unicode literals syntax from python2
Diffstat (limited to 'tests/db')
-rw-r--r--tests/db/test_envelope.py4
-rw-r--r--tests/db/test_message.py8
-rw-r--r--tests/db/test_utils.py106
3 files changed, 59 insertions, 59 deletions
diff --git a/tests/db/test_envelope.py b/tests/db/test_envelope.py
index 873f0927..be318b0d 100644
--- a/tests/db/test_envelope.py
+++ b/tests/db/test_envelope.py
@@ -62,8 +62,8 @@ class TestEnvelope(unittest.TestCase):
def test_setitem_stores_text_unchanged(self):
"Just ensure that the value is set and unchanged"
e = envelope.Envelope()
- e['Subject'] = u'sm\xf8rebr\xf8d'
- self.assertEqual(e['Subject'], u'sm\xf8rebr\xf8d')
+ e['Subject'] = 'sm\xf8rebr\xf8d'
+ self.assertEqual(e['Subject'], 'sm\xf8rebr\xf8d')
def _test_mail(self, envelope):
mail = envelope.construct_mail()
diff --git a/tests/db/test_message.py b/tests/db/test_message.py
index 2f7a6b8c..adc099f6 100644
--- a/tests/db/test_message.py
+++ b/tests/db/test_message.py
@@ -91,8 +91,8 @@ class TestMessage(unittest.TestCase):
is present.
"""
acc = mock.Mock()
- acc.address = account.Address(u'user', u'example.com')
- acc.realname = u'User Name'
+ acc.address = account.Address('user', 'example.com')
+ acc.realname = 'User Name'
with mock.patch('alot.db.message.settings.get_accounts',
mock.Mock(return_value=[acc])):
msg = message.Message(
@@ -104,8 +104,8 @@ class TestMessage(unittest.TestCase):
the message is not a draft.
"""
acc = mock.Mock()
- acc.address = account.Address(u'user', u'example.com')
- acc.realname = u'User Name'
+ acc.address = account.Address('user', 'example.com')
+ acc.realname = 'User Name'
with mock.patch('alot.db.message.settings.get_accounts',
mock.Mock(return_value=[acc])):
msg = message.Message(mock.Mock(), MockNotmuchMessage())
diff --git a/tests/db/test_utils.py b/tests/db/test_utils.py
index 5fe7099f..98a8247c 100644
--- a/tests/db/test_utils.py
+++ b/tests/db/test_utils.py
@@ -132,37 +132,37 @@ class TestExtractHeader(unittest.TestCase):
if not line:
break
expected.append(line)
- expected = u'\n'.join(expected) + u'\n'
+ expected = '\n'.join(expected) + '\n'
self.assertEqual(actual, expected)
def test_single_headers_can_be_retrieved(self):
actual = utils.extract_headers(self.mail, ['from'])
- expected = u'from: me\n'
+ expected = 'from: me\n'
self.assertEqual(actual, expected)
def test_multible_headers_can_be_retrieved_in_predevined_order(self):
headers = ['x-header', 'to', 'x-uppercase']
actual = utils.extract_headers(self.mail, headers)
- expected = u'x-header: param=one; and=two; or=three\nto: you\n' \
- u'x-uppercase: PARAM1=ONE; PARAM2=TWO\n'
+ expected = 'x-header: param=one; and=two; or=three\nto: you\n' \
+ 'x-uppercase: PARAM1=ONE; PARAM2=TWO\n'
self.assertEqual(actual, expected)
def test_headers_can_be_retrieved_multible_times(self):
headers = ['from', 'from']
actual = utils.extract_headers(self.mail, headers)
- expected = u'from: me\nfrom: me\n'
+ expected = 'from: me\nfrom: me\n'
self.assertEqual(actual, expected)
def test_case_is_prserved_in_header_keys_but_irelevant(self):
headers = ['FROM', 'from']
actual = utils.extract_headers(self.mail, headers)
- expected = u'FROM: me\nfrom: me\n'
+ expected = 'FROM: me\nfrom: me\n'
self.assertEqual(actual, expected)
@unittest.expectedFailure
def test_header_values_are_not_decoded(self):
actual = utils.extract_headers(self.mail, ['x-quoted'])
- expected = u"x-quoted: param=utf-8''%C3%9Cmlaut; second=plain%C3%9C\n",
+ expected = "x-quoted: param=utf-8''%C3%9Cmlaut; second=plain%C3%9C\n",
self.assertEqual(actual, expected)
@@ -207,78 +207,78 @@ class TestDecodeHeader(unittest.TestCase):
self.assertEqual(actual, expected)
def test_non_ascii_strings_are_returned_as_unicode_directly(self):
- text = u'Nön ÄSCII string¡'
+ text = 'Nön ÄSCII string¡'
self._test(text, text)
def test_basic_utf_8_quoted(self):
- expected = u'ÄÖÜäöü'
+ expected = 'ÄÖÜäöü'
text = self._quote(expected, 'utf-8')
self._test(text, expected)
def test_basic_iso_8859_1_quoted(self):
- expected = u'ÄÖÜäöü'
+ expected = 'ÄÖÜäöü'
text = self._quote(expected, 'iso-8859-1')
self._test(text, expected)
def test_basic_windows_1252_quoted(self):
- expected = u'ÄÖÜäöü'
+ expected = 'ÄÖÜäöü'
text = self._quote(expected, 'windows-1252')
self._test(text, expected)
def test_basic_utf_8_base64(self):
- expected = u'ÄÖÜäöü'
+ expected = 'ÄÖÜäöü'
text = self._base64(expected, 'utf-8')
self._test(text, expected)
def test_basic_iso_8859_1_base64(self):
- expected = u'ÄÖÜäöü'
+ expected = 'ÄÖÜäöü'
text = self._base64(expected, 'iso-8859-1')
self._test(text, expected)
def test_basic_iso_1252_base64(self):
- expected = u'ÄÖÜäöü'
+ expected = 'ÄÖÜäöü'
text = self._base64(expected, 'windows-1252')
self._test(text, expected)
def test_quoted_words_can_be_interrupted(self):
- part = u'ÄÖÜäöü'
+ part = 'ÄÖÜäöü'
text = self._base64(part, 'utf-8') + ' and ' + \
self._quote(part, 'utf-8')
- expected = u'ÄÖÜäöü and ÄÖÜäöü'
+ expected = 'ÄÖÜäöü and ÄÖÜäöü'
self._test(text, expected)
def test_different_encodings_can_be_mixed(self):
- part = u'ÄÖÜäöü'
+ part = 'ÄÖÜäöü'
text = 'utf-8: ' + self._base64(part, 'utf-8') + \
' again: ' + self._quote(part, 'utf-8') + \
' latin1: ' + self._base64(part, 'iso-8859-1') + \
' and ' + self._quote(part, 'iso-8859-1')
expected = (
- u'utf-8: ÄÖÜäöü '
- u'again: ÄÖÜäöü '
- u'latin1: ÄÖÜäöü and ÄÖÜäöü'
+ 'utf-8: ÄÖÜäöü '
+ 'again: ÄÖÜäöü '
+ 'latin1: ÄÖÜäöü and ÄÖÜäöü'
)
self._test(text, expected)
def test_tabs_are_expanded_to_align_with_eigth_spaces(self):
text = 'tab: \t'
- expected = u'tab: '
+ expected = 'tab: '
self._test(text, expected)
def test_newlines_are_not_touched_by_default(self):
text = 'first\nsecond\n third\n fourth'
- expected = u'first\nsecond\n third\n fourth'
+ expected = 'first\nsecond\n third\n fourth'
self._test(text, expected)
def test_continuation_newlines_can_be_normalized(self):
text = 'first\nsecond\n third\n\tfourth\n \t fifth'
- expected = u'first\nsecond third fourth fifth'
+ expected = 'first\nsecond third fourth fifth'
actual = utils.decode_header(text, normalize=True)
self.assertEqual(actual, expected)
def test_exchange_quotes_remain(self):
# issue #1347
- expected = u'"Mouse, Michaël" <x@y.z>'
+ expected = '"Mouse, Michaël" <x@y.z>'
text = self._quote(expected, 'utf-8')
self._test(text, expected)
@@ -292,7 +292,7 @@ class TestAddSignatureHeaders(unittest.TestCase):
def add_header(self, header, value):
self.headers.append((header, value))
- def check(self, key, valid, error_msg=u''):
+ def check(self, key, valid, error_msg=''):
mail = self.FakeMail()
with mock.patch('alot.db.utils.crypto.get_key',
@@ -305,55 +305,55 @@ class TestAddSignatureHeaders(unittest.TestCase):
def test_length_0(self):
mail = self.FakeMail()
- utils.add_signature_headers(mail, [], u'')
- self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers)
+ utils.add_signature_headers(mail, [], '')
+ self.assertIn((utils.X_SIGNATURE_VALID_HEADER, 'False'), mail.headers)
self.assertIn(
- (utils.X_SIGNATURE_MESSAGE_HEADER, u'Invalid: no signature found'),
+ (utils.X_SIGNATURE_MESSAGE_HEADER, 'Invalid: no signature found'),
mail.headers)
def test_valid(self):
key = make_key()
mail = self.check(key, True)
- self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'True'), mail.headers)
+ self.assertIn((utils.X_SIGNATURE_VALID_HEADER, 'True'), mail.headers)
self.assertIn(
- (utils.X_SIGNATURE_MESSAGE_HEADER, u'Valid: mocked'), mail.headers)
+ (utils.X_SIGNATURE_MESSAGE_HEADER, 'Valid: mocked'), mail.headers)
def test_untrusted(self):
key = make_key()
mail = self.check(key, False)
- self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'True'), mail.headers)
+ self.assertIn((utils.X_SIGNATURE_VALID_HEADER, 'True'), mail.headers)
self.assertIn(
- (utils.X_SIGNATURE_MESSAGE_HEADER, u'Untrusted: mocked'),
+ (utils.X_SIGNATURE_MESSAGE_HEADER, 'Untrusted: mocked'),
mail.headers)
def test_unicode_as_bytes(self):
mail = self.FakeMail()
key = make_key()
- key.uids = [make_uid('andreá@example.com', uid=u'Andreá')]
+ key.uids = [make_uid('andreá@example.com', uid='Andreá')]
mail = self.check(key, True)
- self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'True'), mail.headers)
+ self.assertIn((utils.X_SIGNATURE_VALID_HEADER, 'True'), mail.headers)
self.assertIn(
- (utils.X_SIGNATURE_MESSAGE_HEADER, u'Valid: Andreá'),
+ (utils.X_SIGNATURE_MESSAGE_HEADER, 'Valid: Andreá'),
mail.headers)
def test_error_message_unicode(self):
- mail = self.check(mock.Mock(), mock.Mock(), u'error message')
- self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers)
+ mail = self.check(mock.Mock(), mock.Mock(), 'error message')
+ self.assertIn((utils.X_SIGNATURE_VALID_HEADER, 'False'), mail.headers)
self.assertIn(
- (utils.X_SIGNATURE_MESSAGE_HEADER, u'Invalid: error message'),
+ (utils.X_SIGNATURE_MESSAGE_HEADER, 'Invalid: error message'),
mail.headers)
def test_get_key_fails(self):
mail = self.FakeMail()
with mock.patch('alot.db.utils.crypto.get_key',
- mock.Mock(side_effect=GPGProblem(u'', 0))):
- utils.add_signature_headers(mail, [mock.Mock(fpr='')], u'')
- self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers)
+ mock.Mock(side_effect=GPGProblem('', 0))):
+ utils.add_signature_headers(mail, [mock.Mock(fpr='')], '')
+ self.assertIn((utils.X_SIGNATURE_VALID_HEADER, 'False'), mail.headers)
self.assertIn(
- (utils.X_SIGNATURE_MESSAGE_HEADER, u'Untrusted: '),
+ (utils.X_SIGNATURE_MESSAGE_HEADER, 'Untrusted: '),
mail.headers)
@@ -395,7 +395,7 @@ class TestMessageFromFile(TestCaseClassCleanup):
self.assertIs(message.get(utils.X_SIGNATURE_MESSAGE_HEADER), None)
def test_plain_mail(self):
- m = email.mime.text.MIMEText(u'This is some text', 'plain', 'utf-8')
+ m = email.mime.text.MIMEText('This is some text', 'plain', 'utf-8')
m['Subject'] = 'test'
m['From'] = 'me'
m['To'] = 'Nobody'
@@ -718,7 +718,7 @@ class TestMessageFromString(unittest.TestCase):
"""
def test(self):
- m = email.mime.text.MIMEText(u'This is some text', 'plain', 'utf-8')
+ m = email.mime.text.MIMEText('This is some text', 'plain', 'utf-8')
m['Subject'] = 'test'
m['From'] = 'me'
m['To'] = 'Nobody'
@@ -797,15 +797,15 @@ class _AccountTestClass(Account):
class TestClearMyAddress(unittest.TestCase):
- me1 = u'me@example.com'
- me2 = u'ME@example.com'
- me3 = u'me+label@example.com'
- me4 = u'ME+label@example.com'
+ me1 = 'me@example.com'
+ me2 = 'ME@example.com'
+ me3 = 'me+label@example.com'
+ me4 = 'ME+label@example.com'
me_regex = r'me\+.*@example.com'
- me_named = u'alot team <me@example.com>'
- you = u'you@example.com'
- named = u'somebody you know <somebody@example.com>'
- imposter = u'alot team <imposter@example.com>'
+ me_named = 'alot team <me@example.com>'
+ you = 'you@example.com'
+ named = 'somebody you know <somebody@example.com>'
+ imposter = 'alot team <imposter@example.com>'
mine = _AccountTestClass(
address=me1, aliases=[], alias_regexp=me_regex, case_sensitive_username=True)
@@ -841,7 +841,7 @@ class TestClearMyAddress(unittest.TestCase):
class TestFormataddr(unittest.TestCase):
- address = u'me@example.com'
+ address = 'me@example.com'
umlauts_and_comma = '"Ö, Ä" <a@b.c>'
def test_is_inverse(self):