From 3c31574cf967dd7b01b86884bd821589e693d371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Sun, 10 Sep 2017 12:21:10 +0200 Subject: [PATCH] Unittest: replace deprecated functions --- test/integration/test_gui_event_integration.py | 2 +- test/integration/test_roster.py | 14 +++++++------- test/test_pluginmanager.py | 8 ++++---- test/unit/test_account.py | 2 +- test/unit/test_caps_cache.py | 4 ++-- test/unit/test_sessions.py | 12 ++++++------ test/unit/test_socks5.py | 8 ++++---- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/integration/test_gui_event_integration.py b/test/integration/test_gui_event_integration.py index f7600d8ce..150f2102a 100644 --- a/test/integration/test_gui_event_integration.py +++ b/test/integration/test_gui_event_integration.py @@ -101,7 +101,7 @@ class TestStatusChange(unittest.TestCase): break if not still_exists: - self.assert_(contact is None) + self.assertTrue(contact is None) return self.assertEqual('offline', contact.show) diff --git a/test/integration/test_roster.py b/test/integration/test_roster.py index 8c0e322de..3b5859d65 100644 --- a/test/integration/test_roster.py +++ b/test/integration/test_roster.py @@ -74,13 +74,13 @@ class TestRosterWindow(unittest.TestCase): c_model = self.roster.model[titerC] # name can be stricked if contact or group is blocked -# self.assertEquals(contact.get_shown_name(), c_model[self.C_NAME], +# self.assertEqual(contact.get_shown_name(), c_model[self.C_NAME], # msg='Contact name missmatch') - self.assertEquals(contact.jid, c_model[self.C_JID], + self.assertEqual(contact.jid, c_model[self.C_JID], msg='Jid missmatch') if not self.roster.regroup: - self.assertEquals(account, c_model[self.C_ACCOUNT], + self.assertEqual(account, c_model[self.C_ACCOUNT], msg='Account missmatch') # Check for correct nesting @@ -111,15 +111,15 @@ class TestRosterWindow(unittest.TestCase): msg='Account iter is invalid') acc_model = self.roster.model[titerA] - self.assertEquals(acc_model[self.C_TYPE], 'account', + self.assertEqual(acc_model[self.C_TYPE], 'account', msg='No account found') if not self.roster.regroup: - self.assertEquals(acc_model[self.C_ACCOUNT], acc, + self.assertEqual(acc_model[self.C_ACCOUNT], acc, msg='Account not found') self_jid = app.get_jid_from_account(acc) - self.assertEquals(acc_model[self.C_JID], self_jid, + self.assertEqual(acc_model[self.C_JID], self_jid, msg='Account JID not found in account row') def assert_model_is_in_sync(self): @@ -139,7 +139,7 @@ class TestRosterWindow(unittest.TestCase): # Contacts kept their info contact = instances[0] - self.assertEquals(sorted(contact.groups), sorted(contacts[acc][jid]['groups']), + self.assertEqual(sorted(contact.groups), sorted(contacts[acc][jid]['groups']), msg='Group Missmatch') groups = contacts[acc][jid]['groups'] or ['General',] diff --git a/test/test_pluginmanager.py b/test/test_pluginmanager.py index fa990b64d..24f2046aa 100644 --- a/test/test_pluginmanager.py +++ b/test/test_pluginmanager.py @@ -77,10 +77,10 @@ class PluginManagerTestCase(unittest.TestCase): self.pluginmanager.test_arg = 1 secondPluginManager = PluginManager() - self.failUnlessEqual(id(secondPluginManager), id(self.pluginmanager), - 'Different IDs in references to PluginManager objects (not a singleton)') - self.failUnlessEqual(secondPluginManager.test_arg, 1, - 'References point to different PluginManager objects (not a singleton') + self.assertEqual(id(secondPluginManager), id(self.pluginmanager), + 'Different IDs in references to PluginManager objects (not a singleton)') + self.assertEqual(secondPluginManager.test_arg, 1, + 'References point to different PluginManager objects (not a singleton') def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(PluginManagerTestCase) diff --git a/test/unit/test_account.py b/test/unit/test_account.py index 40c8d223c..60c6eca96 100644 --- a/test/unit/test_account.py +++ b/test/unit/test_account.py @@ -13,7 +13,7 @@ class Test(unittest.TestCase): def testInstantiate(self): account = Account(name='MyAcc', contacts=None, gc_contacts=None) - self.assertEquals('MyAcc', account.name) + self.assertEqual('MyAcc', account.name) self.assertTrue(account.gc_contacts is None) self.assertTrue(account.contacts is None) diff --git a/test/unit/test_caps_cache.py b/test/unit/test_caps_cache.py index 8ddb7d76f..a0bbdd545 100644 --- a/test/unit/test_caps_cache.py +++ b/test/unit/test_caps_cache.py @@ -44,8 +44,8 @@ class TestCapsCache(CommonCapsTest): self.cc[self.client_caps].identities = self.identities self.cc[self.client_caps].features = self.features - self.assert_(NS_MUC in self.cc[self.client_caps].features) - self.assert_(NS_PING not in self.cc[self.client_caps].features) + self.assertTrue(NS_MUC in self.cc[self.client_caps].features) + self.assertTrue(NS_PING not in self.cc[self.client_caps].features) identities = self.cc[self.client_caps].identities diff --git a/test/unit/test_sessions.py b/test/unit/test_sessions.py index d7ea32b7a..d2662dee1 100644 --- a/test/unit/test_sessions.py +++ b/test/unit/test_sessions.py @@ -39,15 +39,15 @@ class TestStanzaSession(unittest.TestCase): def test_generate_thread_id(self): # thread_id is a string - self.assert_(isinstance(self.sess.thread_id, str)) + self.assertTrue(isinstance(self.sess.thread_id, str)) # it should be somewhat long, to avoid clashes - self.assert_(len(self.sess.thread_id) >= 32) + self.assertTrue(len(self.sess.thread_id) >= 32) def test_is_loggable(self): # by default a session should be loggable # (unless the no_log_for setting says otherwise) - self.assert_(self.sess.is_loggable()) + self.assertTrue(self.sess.is_loggable()) def test_terminate(self): # termination is sent by default @@ -127,7 +127,7 @@ class TestChatControlSession(unittest.TestCase): self.assert_new_message_notification() notif = notify.notifications[-1] first = notif.first_unread - self.assert_(first, + self.assertTrue(first, 'message should have been treated as a first message') def assert_not_first_message_notification(self): @@ -135,7 +135,7 @@ class TestChatControlSession(unittest.TestCase): self.assert_new_message_notification() notif = notify.notifications[-1] first = notif.first_unread - self.assert_(not first, + self.assertTrue(not first, 'message was unexpectedly treated as a first message') # ----- tests ----- @@ -148,7 +148,7 @@ class TestChatControlSession(unittest.TestCase): self.receive_chat_msg(fjid, msgtxt) # session is created - self.assert_((jid in self.conn.sessions) and ( + self.assertTrue((jid in self.conn.sessions) and ( '123' in self.conn.sessions[jid]), 'session is not created') sess = self.conn.sessions[jid]['123'] diff --git a/test/unit/test_socks5.py b/test/unit/test_socks5.py index 63ba1d240..c7f85aa0f 100644 --- a/test/unit/test_socks5.py +++ b/test/unit/test_socks5.py @@ -114,10 +114,10 @@ class TestSocks5(unittest.TestCase): s.connect(server) s.send(mocksock.outgoing.pop(0)) - self.assertEquals(s.recv(64), mocksock.incoming.pop(0)) + self.assertEqual(s.recv(64), mocksock.incoming.pop(0)) s.send(mocksock.outgoing.pop(0)) - self.assertEquals(s.recv(64), mocksock.incoming.pop(0)) + self.assertEqual(s.recv(64), mocksock.incoming.pop(0)) def test_connection_client(self): @@ -138,12 +138,12 @@ class TestSocks5(unittest.TestCase): (s, address) = s.accept() - self.assertEquals(s.recv(64), mocksock.incoming.pop(0)) + self.assertEqual(s.recv(64), mocksock.incoming.pop(0)) s.send(mocksock.outgoing.pop(0)) buff = s.recv(64) inco = mocksock.incoming.pop(0) - #self.assertEquals(s.recv(64), mocksock.incoming.pop(0)) + #self.assertEqual(s.recv(64), mocksock.incoming.pop(0)) s.send(mocksock.outgoing.pop(0)) def test_client_negoc(self):