Move unit tests in source folder
darcs-hash:20070513183302-86b55-98a5e67621ece44958f215e98ba1c92e32c4ea51.gz
This commit is contained in:
25
run_tests.py
25
run_tests.py
@@ -32,31 +32,14 @@ reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
del sys.setdefaultencoding
|
||||
|
||||
import tests
|
||||
from tests.jmc.jabber.test_component import *
|
||||
from tests.jmc.model.test_account import *
|
||||
from tests.jmc.test_lang import *
|
||||
|
||||
import jmc
|
||||
import jmc.jabber
|
||||
import jmc.jabber.component
|
||||
|
||||
def test_suite():
|
||||
mail_account_suite = unittest.makeSuite(MailAccount_TestCase, "test")
|
||||
imap_account_suite = unittest.makeSuite(IMAPAccount_TestCase, "test")
|
||||
pop3_account_suite = unittest.makeSuite(POP3Account_TestCase, "test")
|
||||
lang_suite = unittest.makeSuite(Lang_TestCase, "test")
|
||||
mail_component_suite = unittest.makeSuite(MailComponent_TestCase, "test")
|
||||
import jmc.tests as jmc
|
||||
|
||||
# jmc_suite = unittest.TestSuite((mail_component_suite))
|
||||
# jmc_suite = unittest.TestSuite()
|
||||
# jmc_suite.addTest(MailAccount_TestCase('test_format_message_summary_partial_encoded'))
|
||||
jmc_suite = unittest.TestSuite((lang_suite, \
|
||||
mail_account_suite, \
|
||||
imap_account_suite, \
|
||||
pop3_account_suite, \
|
||||
mail_component_suite))
|
||||
return jmc_suite
|
||||
def suite():
|
||||
return jmc.suite()
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = logging.getLogger()
|
||||
@@ -66,7 +49,7 @@ if __name__ == '__main__':
|
||||
coverage.erase()
|
||||
coverage.start()
|
||||
|
||||
unittest.main()
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
coverage.stop()
|
||||
coverage.analysis(jmc.jabber.component)
|
||||
|
||||
2
setup.py
2
setup.py
@@ -31,4 +31,4 @@ setup(name = 'jmc', \
|
||||
package_dir = {'': 'src'}, \
|
||||
packages = ['jmc', 'jmc.jabber', 'jmc.model'], \
|
||||
scripts = ['src/jmc.py'], \
|
||||
test_suite = 'run_tests.test_suite')
|
||||
test_suite = 'jmc.tests.suite')
|
||||
|
||||
14
src/jmc/jabber/tests/__init__.py
Normal file
14
src/jmc/jabber/tests/__init__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""JMC test module"""
|
||||
__revision__ = ""
|
||||
|
||||
import unittest
|
||||
|
||||
from jmc.jabber.tests import component
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(component.suite())
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
@@ -503,3 +503,8 @@ class MailComponent_TestCase(unittest.TestCase):
|
||||
self.assertTrue(account11.marked_all_as_read)
|
||||
del account.hub.threadConnection
|
||||
|
||||
def suite():
|
||||
return unittest.makeSuite(MailComponent_TestCase, 'test')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
@@ -133,7 +133,7 @@ class MailAccount(PresenceAccount):
|
||||
# Define constants
|
||||
DIGEST = 1
|
||||
RETRIEVE = 2
|
||||
default_encoding = "iso-8859-1"
|
||||
default_encoding = "utf-8"
|
||||
possibles_actions = [PresenceAccount.DO_NOTHING, \
|
||||
DIGEST, \
|
||||
RETRIEVE]
|
||||
@@ -223,13 +223,13 @@ class MailAccount(PresenceAccount):
|
||||
if content_charset:
|
||||
result = unicode(part.get_payload(decode=True).decode(content_charset))
|
||||
else:
|
||||
result = unicode(part.get_payload(decode=True))
|
||||
result = unicode(part.get_payload(decode=True).decode(MailAccount.default_encoding))
|
||||
except Exception, e:
|
||||
try:
|
||||
result = unicode(part.get_payload(decode=True).decode("iso-8859-1"))
|
||||
result = unicode(part.get_payload(decode=True))
|
||||
except Exception, e:
|
||||
try:
|
||||
result = unicode(part.get_payload(decode=True).decode(default_encoding))
|
||||
result = unicode(part.get_payload(decode=True).decode("iso-8859-1"))
|
||||
except Exception, e:
|
||||
if charset_hint is not None:
|
||||
try:
|
||||
@@ -252,13 +252,13 @@ class MailAccount(PresenceAccount):
|
||||
charset_hint = from_decoded[i][1]
|
||||
email_from += unicode(from_decoded[i][0].decode(from_decoded[i][1]))
|
||||
else:
|
||||
email_from += unicode(from_decoded[i][0])
|
||||
email_from += unicode(from_decoded[i][0].decode(MailAccount.default_encoding))
|
||||
except Exception,e:
|
||||
try:
|
||||
email_from += unicode(from_decoded[i][0].decode("iso-8859-1"))
|
||||
email_from += unicode(from_decoded[i][0])
|
||||
except Exception, e:
|
||||
try:
|
||||
email_from += unicode(from_decoded[i][0].decode(default_encoding))
|
||||
email_from += unicode(from_decoded[i][0].decode("iso-8859-1"))
|
||||
except Exception, e:
|
||||
type, value, stack = sys.exc_info()
|
||||
print >>sys.stderr, "".join(traceback.format_exception
|
||||
@@ -273,13 +273,13 @@ class MailAccount(PresenceAccount):
|
||||
charset_hint = subject_decoded[i][1]
|
||||
result += unicode(subject_decoded[i][0].decode(subject_decoded[i][1]))
|
||||
else:
|
||||
result += unicode(subject_decoded[i][0])
|
||||
result += unicode(subject_decoded[i][0].decode(MailAccount.default_encoding))
|
||||
except Exception,e:
|
||||
try:
|
||||
result += unicode(subject_decoded[i][0].decode("iso-8859-1"))
|
||||
result += unicode(subject_decoded[i][0])
|
||||
except Exception, e:
|
||||
try:
|
||||
result += unicode(subject_decoded[i][0].decode(default_encoding))
|
||||
result += unicode(subject_decoded[i][0].decode("iso-8859-1"))
|
||||
except Exception, e:
|
||||
if charset_hint is not None:
|
||||
try:
|
||||
|
||||
14
src/jmc/model/tests/__init__.py
Normal file
14
src/jmc/model/tests/__init__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""JMC test module"""
|
||||
__revision__ = ""
|
||||
|
||||
import unittest
|
||||
|
||||
from jmc.model.tests import account
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(account.suite())
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
@@ -34,7 +34,7 @@ from jcl.model.account import Account, PresenceAccount
|
||||
from jmc.model.account import MailAccount, POP3Account, IMAPAccount
|
||||
|
||||
from jcl.model.tests.account import PresenceAccount_TestCase
|
||||
from tests.jmc import email_generator, dummy_server
|
||||
from jmc.model.tests import email_generator, server
|
||||
|
||||
if sys.platform == "win32":
|
||||
DB_PATH = "/c|/temp/test.db"
|
||||
@@ -184,7 +184,7 @@ class POP3Account_TestCase(unittest.TestCase):
|
||||
|
||||
def make_test(responses = None, queries = None, core = None):
|
||||
def inner(self):
|
||||
self.server = dummy_server.DummyServer("localhost", 1110)
|
||||
self.server = server.DummyServer("localhost", 1110)
|
||||
thread.start_new_thread(self.server.serve, ())
|
||||
self.server.responses = ["+OK connected\r\n", \
|
||||
"+OK name is a valid mailbox\r\n", \
|
||||
@@ -314,7 +314,7 @@ class IMAPAccount_TestCase(unittest.TestCase):
|
||||
|
||||
def make_test(responses = None, queries = None, core = None):
|
||||
def inner(self):
|
||||
self.server = dummy_server.DummyServer("localhost", 1143)
|
||||
self.server = server.DummyServer("localhost", 1143)
|
||||
thread.start_new_thread(self.server.serve, ())
|
||||
self.server.responses = ["* OK [CAPABILITY IMAP4 LOGIN-REFERRALS " + \
|
||||
"AUTH=PLAIN]\n", \
|
||||
@@ -387,3 +387,14 @@ class IMAPAccount_TestCase(unittest.TestCase):
|
||||
def test_get_register_fields(self):
|
||||
register_fields = IMAPAccount.get_register_fields()
|
||||
self.assertEquals(len(register_fields), 15)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(MailAccount_TestCase, 'test'))
|
||||
suite.addTest(unittest.makeSuite(POP3Account_TestCase, 'test'))
|
||||
suite.addTest(unittest.makeSuite(IMAPAccount_TestCase, 'test'))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
18
src/jmc/tests/__init__.py
Normal file
18
src/jmc/tests/__init__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""JMC test module"""
|
||||
__revision__ = ""
|
||||
|
||||
import unittest
|
||||
|
||||
from jmc.tests import lang
|
||||
from jmc.jabber import tests as jabber
|
||||
from jmc.model import tests as model
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(lang.suite())
|
||||
suite.addTest(jabber.suite())
|
||||
suite.addTest(model.suite())
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
@@ -20,6 +20,7 @@
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##
|
||||
# TODO : Reuse JCL Lang tests
|
||||
|
||||
import unittest
|
||||
from jmc.lang import Lang
|
||||
@@ -63,3 +64,8 @@ class Lang_TestCase(unittest.TestCase):
|
||||
lang = self.lang.get_lang_class_from_node(iq_node)
|
||||
self.assertEquals(lang, Lang.fr)
|
||||
|
||||
def suite():
|
||||
return unittest.makeSuite(Lang_TestCase, 'test')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
||||
@@ -1,2 +0,0 @@
|
||||
"""JMC test module"""
|
||||
__revision__ = ""
|
||||
@@ -1,2 +0,0 @@
|
||||
"""JMC jabber test module"""
|
||||
__revision__ = ""
|
||||
Reference in New Issue
Block a user