summaryrefslogtreecommitdiff
path: root/tests
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
parentbbb96525c08f0c6ee9fc93e0dd0ccb3abfd1dca8 (diff)
Remove unicode literals syntax from python2
Diffstat (limited to 'tests')
-rw-r--r--tests/addressbook/test_external.py2
-rw-r--r--tests/commands/test_envelope.py16
-rw-r--r--tests/commands/test_global.py28
-rw-r--r--tests/commands/test_init.py2
-rw-r--r--tests/commands/test_thread.py78
-rw-r--r--tests/db/test_envelope.py4
-rw-r--r--tests/db/test_message.py8
-rw-r--r--tests/db/test_utils.py106
-rw-r--r--tests/settings/test_manager.py6
-rw-r--r--tests/test_account.py16
-rw-r--r--tests/test_crypto.py6
-rw-r--r--tests/test_helper.py70
-rw-r--r--tests/utilities.py4
-rw-r--r--tests/widgets/test_globals.py2
14 files changed, 174 insertions, 174 deletions
diff --git a/tests/addressbook/test_external.py b/tests/addressbook/test_external.py
index e38ec9e5..7a9ae983 100644
--- a/tests/addressbook/test_external.py
+++ b/tests/addressbook/test_external.py
@@ -24,7 +24,7 @@ class TestExternalAddressbookGetContacts(unittest.TestCase):
with self._patch_call_cmd(('', '', 42)):
with self.assertRaises(external.AddressbookError) as contextmgr:
abook.get_contacts()
- expected = u'abook command "foobar" returned with return code 42'
+ expected = 'abook command "foobar" returned with return code 42'
self.assertEqual(contextmgr.exception.args[0], expected)
def test_stderr_of_failing_command_is_part_of_exception_message(self):
diff --git a/tests/commands/test_envelope.py b/tests/commands/test_envelope.py
index a5d86d94..d14cbf1f 100644
--- a/tests/commands/test_envelope.py
+++ b/tests/commands/test_envelope.py
@@ -120,28 +120,28 @@ class TestTagCommands(unittest.TestCase):
self.assertListEqual(sorted(actual), sorted(expected))
def test_add_new_tags(self):
- self._test(u'four', 'add', ['one', 'two', 'three', 'four'])
+ self._test('four', 'add', ['one', 'two', 'three', 'four'])
def test_adding_existing_tags_has_no_effect(self):
- self._test(u'one', 'add', ['one', 'two', 'three'])
+ self._test('one', 'add', ['one', 'two', 'three'])
def test_remove_existing_tags(self):
- self._test(u'one', 'remove', ['two', 'three'])
+ self._test('one', 'remove', ['two', 'three'])
def test_remove_non_existing_tags_has_no_effect(self):
- self._test(u'four', 'remove', ['one', 'two', 'three'])
+ self._test('four', 'remove', ['one', 'two', 'three'])
def test_set_tags(self):
- self._test(u'a,b,c', 'set', ['a', 'b', 'c'])
+ self._test('a,b,c', 'set', ['a', 'b', 'c'])
def test_toggle_will_remove_existing_tags(self):
- self._test(u'one', 'toggle', ['two', 'three'])
+ self._test('one', 'toggle', ['two', 'three'])
def test_toggle_will_add_new_tags(self):
- self._test(u'four', 'toggle', ['one', 'two', 'three', 'four'])
+ self._test('four', 'toggle', ['one', 'two', 'three', 'four'])
def test_toggle_can_remove_and_add_in_one_run(self):
- self._test(u'one,four', 'toggle', ['two', 'three', 'four'])
+ self._test('one,four', 'toggle', ['two', 'three', 'four'])
class TestSignCommand(unittest.TestCase):
diff --git a/tests/commands/test_global.py b/tests/commands/test_global.py
index 07b0df2a..94ad0672 100644
--- a/tests/commands/test_global.py
+++ b/tests/commands/test_global.py
@@ -84,12 +84,12 @@ class TestComposeCommand(unittest.TestCase):
self.assertIs(envelope.sign_key, None)
def test_get_template_decode(self):
- subject = u'This is a täßϑ subject.'
- to = u'recipient@mail.com'
- _from = u'foo.bar@mail.fr'
- body = u'Body\n地初店会継思識棋御招告外児山望掲領環。\n€mail body €nd.'
+ subject = 'This is a täßϑ subject.'
+ to = 'recipient@mail.com'
+ _from = 'foo.bar@mail.fr'
+ body = 'Body\n地初店会継思識棋御招告外児山望掲領環。\n€mail body €nd.'
with tempfile.NamedTemporaryFile('wb', delete=False) as f:
- txt = u'Subject: {}\nTo: {}\nFrom: {}\n{}'.format(subject, to,
+ txt = 'Subject: {}\nTo: {}\nFrom: {}\n{}'.format(subject, to,
_from, body)
f.write(txt.encode('utf-8'))
self.addCleanup(os.unlink, f.name)
@@ -109,14 +109,14 @@ class TestExternalCommand(unittest.TestCase):
@utilities.async_test
async def test_no_spawn_no_stdin_success(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand(u'true', refocus=False)
+ cmd = g_commands.ExternalCommand('true', refocus=False)
await cmd.apply(ui)
ui.notify.assert_not_called()
@utilities.async_test
async def test_no_spawn_stdin_success(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand(u"awk '{ exit $0 }'", stdin=u'0',
+ cmd = g_commands.ExternalCommand("awk '{ exit $0 }'", stdin='0',
refocus=False)
await cmd.apply(ui)
ui.notify.assert_not_called()
@@ -124,7 +124,7 @@ class TestExternalCommand(unittest.TestCase):
@utilities.async_test
async def test_no_spawn_no_stdin_attached(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand(u'test -t 0', refocus=False)
+ cmd = g_commands.ExternalCommand('test -t 0', refocus=False)
await cmd.apply(ui)
ui.notify.assert_not_called()
@@ -132,7 +132,7 @@ class TestExternalCommand(unittest.TestCase):
async def test_no_spawn_stdin_attached(self):
ui = utilities.make_ui()
cmd = g_commands.ExternalCommand(
- u"test -t 0", stdin=u'0', refocus=False)
+ "test -t 0", stdin='0', refocus=False)
await cmd.apply(ui)
ui.notify.assert_called_once_with(
'editor has exited with error code 1 -- No stderr output',
@@ -141,7 +141,7 @@ class TestExternalCommand(unittest.TestCase):
@utilities.async_test
async def test_no_spawn_failure(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand(u'false', refocus=False)
+ cmd = g_commands.ExternalCommand('false', refocus=False)
await cmd.apply(ui)
ui.notify.assert_called_once_with(
'editor has exited with error code 1 -- No stderr output',
@@ -153,7 +153,7 @@ class TestExternalCommand(unittest.TestCase):
@mock.patch.dict(os.environ, {'DISPLAY': ':0'})
async def test_spawn_no_stdin_success(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand(u'true', refocus=False, spawn=True)
+ cmd = g_commands.ExternalCommand('true', refocus=False, spawn=True)
await cmd.apply(ui)
ui.notify.assert_not_called()
@@ -164,8 +164,8 @@ class TestExternalCommand(unittest.TestCase):
async def test_spawn_stdin_success(self):
ui = utilities.make_ui()
cmd = g_commands.ExternalCommand(
- u"awk '{ exit $0 }'",
- stdin=u'0', refocus=False, spawn=True)
+ "awk '{ exit $0 }'",
+ stdin='0', refocus=False, spawn=True)
await cmd.apply(ui)
ui.notify.assert_not_called()
@@ -175,7 +175,7 @@ class TestExternalCommand(unittest.TestCase):
@mock.patch.dict(os.environ, {'DISPLAY': ':0'})
async def test_spawn_failure(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand(u'false', refocus=False, spawn=True)
+ cmd = g_commands.ExternalCommand('false', refocus=False, spawn=True)
await cmd.apply(ui)
ui.notify.assert_called_once_with(
'editor has exited with error code 1 -- No stderr output',
diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py
index 29828b9a..f7574977 100644
--- a/tests/commands/test_init.py
+++ b/tests/commands/test_init.py
@@ -33,7 +33,7 @@ class TestCommandFactory(unittest.TestCase):
cmd = commands.commandfactory('save --all /foo', mode='thread')
self.assertIsInstance(cmd, thread.SaveAttachmentCommand)
self.assertTrue(cmd.all)
- self.assertEqual(cmd.path, u'/foo')
+ self.assertEqual(cmd.path, '/foo')
class TestRegisterCommand(unittest.TestCase):
diff --git a/tests/commands/test_thread.py b/tests/commands/test_thread.py
index 335ca388..5d25079d 100644
--- a/tests/commands/test_thread.py
+++ b/tests/commands/test_thread.py
@@ -77,77 +77,77 @@ class TestDetermineSender(unittest.TestCase):
self.assertTupleEqual(cm2.exception.args, expected)
def test_default_account_is_used_if_no_match_is_found(self):
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'bar@example.com')
- expected = (u'foo@example.com', account1)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='bar@example.com')
+ expected = ('foo@example.com', account1)
self._test(accounts=[account1, account2], expected=expected)
def test_matching_address_and_account_are_returned(self):
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'to@example.com')
- account3 = _AccountTestClass(address=u'bar@example.com')
- expected = (u'to@example.com', account2)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com')
+ account3 = _AccountTestClass(address='bar@example.com')
+ expected = ('to@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected)
def test_force_realname_has_real_name_in_returned_address_if_defined(self):
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'to@example.com', realname='Bar')
- account3 = _AccountTestClass(address=u'baz@example.com')
- expected = (u'Bar <to@example.com>', account2)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com', realname='Bar')
+ account3 = _AccountTestClass(address='baz@example.com')
+ expected = ('Bar <to@example.com>', account2)
self._test(accounts=[account1, account2, account3], expected=expected,
force_realname=True)
def test_doesnt_fail_with_force_realname_if_real_name_not_defined(self):
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'to@example.com')
- account3 = _AccountTestClass(address=u'bar@example.com')
- expected = (u'to@example.com', account2)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com')
+ account3 = _AccountTestClass(address='bar@example.com')
+ expected = ('to@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected,
force_realname=True)
def test_with_force_address_main_address_is_always_used(self):
# In python 3.4 this and the next test could be written as subtests.
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'bar@example.com',
- aliases=[u'to@example.com'])
- account3 = _AccountTestClass(address=u'bar@example.com')
- expected = (u'bar@example.com', account2)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='bar@example.com',
+ aliases=['to@example.com'])
+ account3 = _AccountTestClass(address='bar@example.com')
+ expected = ('bar@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected,
force_address=True)
def test_without_force_address_matching_address_is_used(self):
# In python 3.4 this and the previous test could be written as
# subtests.
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'bar@example.com',
- aliases=[u'to@example.com'])
- account3 = _AccountTestClass(address=u'baz@example.com')
- expected = (u'to@example.com', account2)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='bar@example.com',
+ aliases=['to@example.com'])
+ account3 = _AccountTestClass(address='baz@example.com')
+ expected = ('to@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected,
force_address=False)
def test_uses_to_header_if_present(self):
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'to@example.com')
- account3 = _AccountTestClass(address=u'bar@example.com')
- expected = (u'to@example.com', account2)
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com')
+ account3 = _AccountTestClass(address='bar@example.com')
+ expected = ('to@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected)
def test_header_order_is_more_important_than_accounts_order(self):
- account1 = _AccountTestClass(address=u'cc@example.com')
- account2 = _AccountTestClass(address=u'to@example.com')
- account3 = _AccountTestClass(address=u'bcc@example.com')
- expected = (u'to@example.com', account2)
+ account1 = _AccountTestClass(address='cc@example.com')
+ account2 = _AccountTestClass(address='to@example.com')
+ account3 = _AccountTestClass(address='bcc@example.com')
+ expected = ('to@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected)
def test_accounts_can_be_found_by_alias_regex_setting(self):
- account1 = _AccountTestClass(address=u'foo@example.com')
- account2 = _AccountTestClass(address=u'to@example.com',
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com',
alias_regexp=r'to\+.*@example.com')
- account3 = _AccountTestClass(address=u'bar@example.com')
- mailstring = self.mailstring.replace(u'to@example.com',
- u'to+some_tag@example.com')
+ account3 = _AccountTestClass(address='bar@example.com')
+ mailstring = self.mailstring.replace('to@example.com',
+ 'to+some_tag@example.com')
mail = email.message_from_string(mailstring)
- expected = (u'to+some_tag@example.com', account2)
+ expected = ('to+some_tag@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected,
mail=mail)
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):
diff --git a/tests/settings/test_manager.py b/tests/settings/test_manager.py
index aa2e1e8d..6548ee82 100644
--- a/tests/settings/test_manager.py
+++ b/tests/settings/test_manager.py
@@ -272,17 +272,17 @@ class TestSettingsManagerGetAccountByAddress(utilities.TestCaseClassCleanup):
cls.manager.read_config(f.name)
def test_exists_addr(self):
- acc = self.manager.account_matching_address(u'that_guy@example.com')
+ acc = self.manager.account_matching_address('that_guy@example.com')
self.assertEqual(acc.realname, 'That Guy')
def test_doesnt_exist_return_default(self):
- acc = self.manager.account_matching_address(u'doesntexist@example.com',
+ acc = self.manager.account_matching_address('doesntexist@example.com',
return_default=True)
self.assertEqual(acc.realname, 'That Guy')
def test_doesnt_exist_raise(self):
with self.assertRaises(NoMatchingAccount):
- self.manager.account_matching_address(u'doesntexist@example.com')
+ self.manager.account_matching_address('doesntexist@example.com')
def test_doesnt_exist_no_default(self):
with tempfile.NamedTemporaryFile() as f:
diff --git a/tests/test_account.py b/tests/test_account.py
index 9d0ac125..975f80ad 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -35,23 +35,23 @@ class TestAccount(unittest.TestCase):
def test_matches_address(self):
"""Tests address without aliases."""
acct = _AccountTestClass(address="foo@example.com")
- self.assertTrue(acct.matches_address(u"foo@example.com"))
- self.assertFalse(acct.matches_address(u"bar@example.com"))
+ self.assertTrue(acct.matches_address("foo@example.com"))
+ self.assertFalse(acct.matches_address("bar@example.com"))
def test_matches_address_with_aliases(self):
"""Tests address with aliases."""
acct = _AccountTestClass(address="foo@example.com",
aliases=['bar@example.com'])
- self.assertTrue(acct.matches_address(u"foo@example.com"))
- self.assertTrue(acct.matches_address(u"bar@example.com"))
- self.assertFalse(acct.matches_address(u"baz@example.com"))
+ self.assertTrue(acct.matches_address("foo@example.com"))
+ self.assertTrue(acct.matches_address("bar@example.com"))
+ self.assertFalse(acct.matches_address("baz@example.com"))
def test_matches_address_with_regex_aliases(self):
"""Tests address with regex aliases."""
- acct = _AccountTestClass(address=u"foo@example.com",
+ acct = _AccountTestClass(address="foo@example.com",
alias_regexp=r'to\+.*@example.com')
- self.assertTrue(acct.matches_address(u"to+foo@example.com"))
- self.assertFalse(acct.matches_address(u"to@example.com"))
+ self.assertTrue(acct.matches_address("to+foo@example.com"))
+ self.assertFalse(acct.matches_address("to@example.com"))
def test_deprecated_encrypt_by_default(self):
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
index 885750b5..8c8b241b 100644
--- a/tests/test_crypto.py
+++ b/tests/test_crypto.py
@@ -70,7 +70,7 @@ def make_key(revoked=False, expired=False, invalid=False, can_encrypt=True,
can_sign=True):
# This is ugly
mock_key = mock.create_autospec(gpg._gpgme._gpgme_key)
- mock_key.uids = [mock.Mock(uid=u'mocked')]
+ mock_key.uids = [mock.Mock(uid='mocked')]
mock_key.revoked = revoked
mock_key.expired = expired
mock_key.invalid = invalid
@@ -267,12 +267,12 @@ class TestListKeys(unittest.TestCase):
def test_list_keys_pub(self):
values = list(crypto.list_keys(hint="ambigu"))[0]
- self.assertEqual(values.uids[0].email, u'amigbu@example.com')
+ self.assertEqual(values.uids[0].email, 'amigbu@example.com')
self.assertFalse(values.secret)
def test_list_keys_private(self):
values = list(crypto.list_keys(hint="ambigu", private=True))[0]
- self.assertEqual(values.uids[0].email, u'amigbu@example.com')
+ self.assertEqual(values.uids[0].email, 'amigbu@example.com')
self.assertTrue(values.secret)
diff --git a/tests/test_helper.py b/tests/test_helper.py
index 51865f15..e75be836 100644
--- a/tests/test_helper.py
+++ b/tests/test_helper.py
@@ -38,7 +38,7 @@ from . import utilities
class TestHelperShortenAuthorString(unittest.TestCase):
- authors = u'King Kong, Mucho Muchacho, Jaime Huerta, Flash Gordon'
+ authors = 'King Kong, Mucho Muchacho, Jaime Huerta, Flash Gordon'
def test_high_maxlength_keeps_string_intact(self):
short = helper.shorten_author_string(self.authors, 60)
@@ -46,23 +46,23 @@ class TestHelperShortenAuthorString(unittest.TestCase):
def test_shows_only_first_names_if_they_fit(self):
short = helper.shorten_author_string(self.authors, 40)
- self.assertEqual(short, u"King, Mucho, Jaime, Flash")
+ self.assertEqual(short, "King, Mucho, Jaime, Flash")
def test_adds_ellipses_to_long_first_names(self):
short = helper.shorten_author_string(self.authors, 20)
- self.assertEqual(short, u"King, …, Jai…, Flash")
+ self.assertEqual(short, "King, …, Jai…, Flash")
def test_replace_all_but_first_name_with_ellipses(self):
short = helper.shorten_author_string(self.authors, 10)
- self.assertEqual(short, u"King, …")
+ self.assertEqual(short, "King, …")
def test_shorten_first_name_with_ellipses(self):
short = helper.shorten_author_string(self.authors, 2)
- self.assertEqual(short, u"K…")
+ self.assertEqual(short, "K…")
def test_only_display_initial_letter_for_maxlength_1(self):
short = helper.shorten_author_string(self.authors, 1)
- self.assertEqual(short, u"K")
+ self.assertEqual(short, "K")
class TestShellQuote(unittest.TestCase):
@@ -125,7 +125,7 @@ class TestSplitCommandline(unittest.TestCase):
self._test(base, expected)
def test_unicode(self):
- base = u'echo "foo";sleep 1'
+ base = 'echo "foo";sleep 1'
expected = ['echo "foo"', 'sleep 1']
self._test(base, expected)
@@ -164,18 +164,18 @@ class TestStringDecode(unittest.TestCase):
self.assertEqual(actual, expected)
def test_ascii_bytes(self):
- base = u'test'.encode('ascii')
- expected = u'test'
+ base = 'test'.encode('ascii')
+ expected = 'test'
self._test(base, expected)
def test_utf8_bytes(self):
- base = u'test'.encode('utf-8')
- expected = u'test'
+ base = 'test'.encode('utf-8')
+ expected = 'test'
self._test(base, expected, 'utf-8')
def test_unicode(self):
- base = u'test'
- expected = u'test'
+ base = 'test'
+ expected = 'test'
self._test(base, expected)
@@ -219,21 +219,21 @@ class TestPrettyDatetime(unittest.TestCase):
for i in (self.random.randint(0, 60) for _ in range(5)):
test = self.now - datetime.timedelta(seconds=i)
actual = helper.pretty_datetime(test)
- self.assertEqual(actual, u'just now')
+ self.assertEqual(actual, 'just now')
def test_x_minutes_ago(self):
for i in (self.random.randint(60, 3600) for _ in range(10)):
test = self.now - datetime.timedelta(seconds=i)
actual = helper.pretty_datetime(test)
self.assertEqual(
- actual, u'{}min ago'.format((self.now - test).seconds // 60))
+ actual, '{}min ago'.format((self.now - test).seconds // 60))
def test_x_hours_ago(self):
for i in (self.random.randint(3600, 3600 * 6) for _ in range(10)):
test = self.now - datetime.timedelta(seconds=i)
actual = helper.pretty_datetime(test)
self.assertEqual(
- actual, u'{}h ago'.format((self.now - test).seconds // 3600))
+ actual, '{}h ago'.format((self.now - test).seconds // 3600))
# TODO: yesterday
# TODO: yesterday > now > a year
@@ -318,45 +318,45 @@ class TestCallCmd(unittest.TestCase):
def test_no_stdin(self):
out, err, code = helper.call_cmd(['echo', '-n', 'foo'])
- self.assertEqual(out, u'foo')
- self.assertEqual(err, u'')
+ self.assertEqual(out, 'foo')
+ self.assertEqual(err, '')
self.assertEqual(code, 0)
def test_no_stdin_unicode(self):
out, err, code = helper.call_cmd(['echo', '-n', '�'])
- self.assertEqual(out, u'�')
- self.assertEqual(err, u'')
+ self.assertEqual(out, '�')
+ self.assertEqual(err, '')
self.assertEqual(code, 0)
def test_stdin(self):
out, err, code = helper.call_cmd(['cat'], stdin='�')
- self.assertEqual(out, u'�')
- self.assertEqual(err, u'')
+ self.assertEqual(out, '�')
+ self.assertEqual(err, '')
self.assertEqual(code, 0)
def test_no_such_command(self):
out, err, code = helper.call_cmd(['thiscommandabsolutelydoesntexist'])
- self.assertEqual(out, u'')
+ self.assertEqual(out, '')
# We don't control the output of err, the shell does. Therefore simply
# assert that the shell said *something*
- self.assertNotEqual(err, u'')
+ self.assertNotEqual(err, '')
self.assertEqual(code, errno.ENOENT)
def test_no_such_command_stdin(self):
out, err, code = helper.call_cmd(['thiscommandabsolutelydoesntexist'],
stdin='foo')
- self.assertEqual(out, u'')
+ self.assertEqual(out, '')
# We don't control the output of err, the shell does. Therefore simply
# assert that the shell said *something*
- self.assertNotEqual(err, u'')
+ self.assertNotEqual(err, '')
self.assertEqual(code, errno.ENOENT)
def test_bad_argument_stdin(self):
out, err, code = helper.call_cmd(['cat', '-Y'], stdin='�')
- self.assertEqual(out, u'')
- self.assertNotEqual(err, u'')
+ self.assertEqual(out, '')
+ self.assertNotEqual(err, '')
# We don't control this, although 1 might be a fairly safe guess, we
# know for certain it should *not* return 0
@@ -364,8 +364,8 @@ class TestCallCmd(unittest.TestCase):
def test_bad_argument(self):
out, err, code = helper.call_cmd(['cat', '-Y'])
- self.assertEqual(out, u'')
- self.assertNotEqual(err, u'')
+ self.assertEqual(out, '')
+ self.assertNotEqual(err, '')
# We don't control this, although 1 might be a fairly safe guess, we
# know for certain it should *not* return 0
@@ -373,18 +373,18 @@ class TestCallCmd(unittest.TestCase):
def test_os_errors_from_popen_are_caught(self):
with mock.patch('subprocess.Popen',
- mock.Mock(side_effect=OSError(42, u'foobar'))):
+ mock.Mock(side_effect=OSError(42, 'foobar'))):
out, err, code = helper.call_cmd(
['does_not_matter_as_subprocess_popen_is_mocked'])
- self.assertEqual(out, u'')
- self.assertEqual(err, u'foobar')
+ self.assertEqual(out, '')
+ self.assertEqual(err, 'foobar')
self.assertEqual(code, 42)
class TestShorten(unittest.TestCase):
def test_lt_maxlen(self):
- expected = u'a string'
+ expected = 'a string'
actual = helper.shorten(expected, 25)
self.assertEqual(expected, actual)
@@ -394,7 +394,7 @@ class TestShorten(unittest.TestCase):
self.assertEqual(expected, actual)
def test_gt_maxlen(self):
- expected = u'a long string…'
+ expected = 'a long string…'
actual = helper.shorten('a long string that is full of text', 14)
self.assertEqual(expected, actual)
diff --git a/tests/utilities.py b/tests/utilities.py
index 35937d09..26aa891e 100644
--- a/tests/utilities.py
+++ b/tests/utilities.py
@@ -147,7 +147,7 @@ class ModuleCleanup(object):
return wrapper
-def make_uid(email, uid=u'mocked', revoked=False, invalid=False,
+def make_uid(email, uid='mocked', revoked=False, invalid=False,
validity=gpg.constants.validity.FULL):
uid_ = mock.Mock()
uid_.email = email
@@ -162,7 +162,7 @@ def make_uid(email, uid=u'mocked', revoked=False, invalid=False,
def make_key(revoked=False, expired=False, invalid=False, can_encrypt=True,
can_sign=True):
mock_key = mock.Mock()
- mock_key.uids = [make_uid(u'foo@example.com')]
+ mock_key.uids = [make_uid('foo@example.com')]
mock_key.revoked = revoked
mock_key.expired = expired
mock_key.invalid = invalid
diff --git a/tests/widgets/test_globals.py b/tests/widgets/test_globals.py
index 72e6f77e..02918402 100644
--- a/tests/widgets/test_globals.py
+++ b/tests/widgets/test_globals.py
@@ -40,7 +40,7 @@ class TestTagWidget(unittest.TestCase):
def test_hash_for_unicode_representation(self):
with mock.patch(
'alot.widgets.globals.settings.get_tagstring_representation',
- lambda _, __, ___: {'translated': u'✉', 'normal': None,
+ lambda _, __, ___: {'translated': '✉', 'normal': None,
'focussed': None}):
# We don't have to assert anything, we just want the hash to be
# computed without an exception. The implementation currently