Skip to content
Snippets Groups Projects
Commit 8a830338 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

add some options to runtests.py to be able to tune verbosity and wether we...

add some options to runtests.py to be able to tune verbosity and wether we want to run tests that require X or not
parent 1e8e0f60
No related branches found
No related tags found
No related merge requests found
import sys
import os.path
import getopt
use_x = True
opts, args = getopt.getopt(sys.argv[1:], 'n', ['no-x'])
for o, a in opts:
if o in ('-n', '--no-x'):
use_x = False
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../..')
......@@ -32,8 +39,10 @@ def setup_env():
from common import gajim
gajim.DATA_DIR = gajim_root + '/data'
gajim.use_x = use_x
import gtkgui_helpers
gtkgui_helpers.GLADE_DIR = gajim_root + '/data/glade'
if use_x:
import gtkgui_helpers
gtkgui_helpers.GLADE_DIR = gajim_root + '/data/glade'
# vim: se ts=3:
......@@ -19,7 +19,8 @@ class MockConnection(Mock, ConnectionHandlersBase):
self.blocked_groups = {}
self.sessions = {}
gajim.interface.instances[account] = {'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}}
gajim.interface.instances[account] = {'infos': {}, 'disco': {},
'gc_config': {}, 'search': {}}
gajim.interface.minimized_controls[account] = {}
gajim.contacts.add_account(account)
gajim.groups[account] = {}
......@@ -91,6 +92,7 @@ class MockChatControl(Mock):
class MockInterface(Mock):
def __init__(self, *args):
Mock.__init__(self, *args)
gajim.interface = self
self.msg_win_mgr = Mock()
self.roster = Mock()
......@@ -99,7 +101,15 @@ class MockInterface(Mock):
self.minimized_controls = {}
self.status_sent_to_users = Mock()
self.jabber_state_images = {'16': Mock(), '32': Mock(), 'opened': Mock(), 'closed': Mock()}
if gajim.use_x:
self.jabber_state_images = {'16': {}, '32': {}, 'opened': {},
'closed': {}}
import gtkgui_helpers
gtkgui_helpers.make_jabber_state_images()
else:
self.jabber_state_images = {'16': Mock(), '32': Mock(),
'opened': Mock(), 'closed': Mock()}
class MockLogger(Mock):
def __init__(self):
......
#!/usr/bin/env python
import sys
import unittest
import getopt
use_x = True
verbose = 1
try:
shortargs = 'hnv:'
longargs = 'help no-x verbose='
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
except getopt.error, msg:
print msg
print 'for help use --help'
sys.exit(2)
for o, a in opts:
if o in ('-h', '--help'):
print 'runtests [--help] [--no-x] [--verbose level]'
sys.exit()
elif o in ('-n', '--no-x'):
use_x = False
elif o in ('-v', '--verbose'):
try:
verbose = int(a)
except:
print 'verbose must be a number >= 0'
# new test modules need to be added manually
modules = ( 'test_caps',
'test_dispatcher_nb',
'test_misc_interface',
'test_roster',
'test_sessions',
)
)
if use_x:
modules += ('test_misc_interface',
'test_roster',
'test_sessions',
)
nb_errors = 0
nb_failures = 0
for mod in modules:
suite = unittest.defaultTestLoader.loadTestsFromName(mod)
unittest.TextTestRunner(verbosity=1).run(suite)
result = unittest.TextTestRunner(verbosity=verbose).run(suite)
nb_errors += len(result.errors)
nb_failures += len(result.failures)
sys.exit(nb_errors + nb_failures)
# vim: se ts=3:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment