Merge branch 'tests' into 'master'

Test: fix some warnings and errors

See merge request !131
This commit is contained in:
Yann Leboulanger 2017-09-11 10:01:16 +02:00
commit 64cfc5ea6e
7 changed files with 27 additions and 28 deletions

View File

@ -101,7 +101,7 @@ class TestStatusChange(unittest.TestCase):
break break
if not still_exists: if not still_exists:
self.assert_(contact is None) self.assertTrue(contact is None)
return return
self.assertEqual('offline', contact.show) self.assertEqual('offline', contact.show)

View File

@ -74,13 +74,13 @@ class TestRosterWindow(unittest.TestCase):
c_model = self.roster.model[titerC] c_model = self.roster.model[titerC]
# name can be stricked if contact or group is blocked # 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') # 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') msg='Jid missmatch')
if not self.roster.regroup: if not self.roster.regroup:
self.assertEquals(account, c_model[self.C_ACCOUNT], self.assertEqual(account, c_model[self.C_ACCOUNT],
msg='Account missmatch') msg='Account missmatch')
# Check for correct nesting # Check for correct nesting
@ -111,15 +111,15 @@ class TestRosterWindow(unittest.TestCase):
msg='Account iter is invalid') msg='Account iter is invalid')
acc_model = self.roster.model[titerA] 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') msg='No account found')
if not self.roster.regroup: 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') msg='Account not found')
self_jid = app.get_jid_from_account(acc) 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') msg='Account JID not found in account row')
def assert_model_is_in_sync(self): def assert_model_is_in_sync(self):
@ -139,7 +139,7 @@ class TestRosterWindow(unittest.TestCase):
# Contacts kept their info # Contacts kept their info
contact = instances[0] 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') msg='Group Missmatch')
groups = contacts[acc][jid]['groups'] or ['General',] groups = contacts[acc][jid]['groups'] or ['General',]

View File

@ -38,8 +38,8 @@ configdir = gajim_root + '/test/tmp'
import time import time
# define _ for i18n # define _ for i18n
import __builtin__ import builtins
__builtin__._ = lambda x: x builtins._ = lambda x: x
# wipe config directory # wipe config directory
import os import os
@ -54,7 +54,6 @@ gajim.common.configpaths.gajimpaths.init(configdir)
# for some reason common.app needs to be imported before xmpppy? # for some reason common.app needs to be imported before xmpppy?
from gajim.common import app from gajim.common import app
from gajim.common import xmpp
app.DATA_DIR = gajim_root + '/data' app.DATA_DIR = gajim_root + '/data'
@ -77,10 +76,10 @@ class PluginManagerTestCase(unittest.TestCase):
self.pluginmanager.test_arg = 1 self.pluginmanager.test_arg = 1
secondPluginManager = PluginManager() secondPluginManager = PluginManager()
self.failUnlessEqual(id(secondPluginManager), id(self.pluginmanager), self.assertEqual(id(secondPluginManager), id(self.pluginmanager),
'Different IDs in references to PluginManager objects (not a singleton)') 'Different IDs in references to PluginManager objects (not a singleton)')
self.failUnlessEqual(secondPluginManager.test_arg, 1, self.assertEqual(secondPluginManager.test_arg, 1,
'References point to different PluginManager objects (not a singleton') 'References point to different PluginManager objects (not a singleton')
def suite(): def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(PluginManagerTestCase) suite = unittest.TestLoader().loadTestsFromTestCase(PluginManagerTestCase)

View File

@ -13,7 +13,7 @@ class Test(unittest.TestCase):
def testInstantiate(self): def testInstantiate(self):
account = Account(name='MyAcc', contacts=None, gc_contacts=None) 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.gc_contacts is None)
self.assertTrue(account.contacts is None) self.assertTrue(account.contacts is None)

View File

@ -44,8 +44,8 @@ class TestCapsCache(CommonCapsTest):
self.cc[self.client_caps].identities = self.identities self.cc[self.client_caps].identities = self.identities
self.cc[self.client_caps].features = self.features self.cc[self.client_caps].features = self.features
self.assert_(NS_MUC in self.cc[self.client_caps].features) self.assertTrue(NS_MUC in self.cc[self.client_caps].features)
self.assert_(NS_PING not 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 identities = self.cc[self.client_caps].identities

View File

@ -39,15 +39,15 @@ class TestStanzaSession(unittest.TestCase):
def test_generate_thread_id(self): def test_generate_thread_id(self):
# thread_id is a string # 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 # 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): def test_is_loggable(self):
# by default a session should be loggable # by default a session should be loggable
# (unless the no_log_for setting says otherwise) # (unless the no_log_for setting says otherwise)
self.assert_(self.sess.is_loggable()) self.assertTrue(self.sess.is_loggable())
def test_terminate(self): def test_terminate(self):
# termination is sent by default # termination is sent by default
@ -127,7 +127,7 @@ class TestChatControlSession(unittest.TestCase):
self.assert_new_message_notification() self.assert_new_message_notification()
notif = notify.notifications[-1] notif = notify.notifications[-1]
first = notif.first_unread first = notif.first_unread
self.assert_(first, self.assertTrue(first,
'message should have been treated as a first message') 'message should have been treated as a first message')
def assert_not_first_message_notification(self): def assert_not_first_message_notification(self):
@ -135,7 +135,7 @@ class TestChatControlSession(unittest.TestCase):
self.assert_new_message_notification() self.assert_new_message_notification()
notif = notify.notifications[-1] notif = notify.notifications[-1]
first = notif.first_unread first = notif.first_unread
self.assert_(not first, self.assertTrue(not first,
'message was unexpectedly treated as a first message') 'message was unexpectedly treated as a first message')
# ----- tests ----- # ----- tests -----
@ -148,7 +148,7 @@ class TestChatControlSession(unittest.TestCase):
self.receive_chat_msg(fjid, msgtxt) self.receive_chat_msg(fjid, msgtxt)
# session is created # 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') '123' in self.conn.sessions[jid]), 'session is not created')
sess = self.conn.sessions[jid]['123'] sess = self.conn.sessions[jid]['123']

View File

@ -114,10 +114,10 @@ class TestSocks5(unittest.TestCase):
s.connect(server) s.connect(server)
s.send(mocksock.outgoing.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))
s.send(mocksock.outgoing.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): def test_connection_client(self):
@ -138,12 +138,12 @@ class TestSocks5(unittest.TestCase):
(s, address) = s.accept() (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)) s.send(mocksock.outgoing.pop(0))
buff = s.recv(64) buff = s.recv(64)
inco = mocksock.incoming.pop(0) 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)) s.send(mocksock.outgoing.pop(0))
def test_client_negoc(self): def test_client_negoc(self):