gajim-plural/test/lib/__init__.py

55 lines
1.4 KiB
Python
Raw Normal View History

2008-06-12 05:56:30 +02:00
import sys
import os
import getopt
use_x = True
shortargs = 'hnv:'
longargs = 'help no-x verbose='
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
for o, a in opts:
if o in ('-n', '--no-x'):
use_x = False
2008-06-12 05:56:30 +02:00
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../..')
2008-06-12 05:56:30 +02:00
2017-06-20 23:07:28 +02:00
# look for modules in the CWD, then gajim/test/lib, then gajim/gajim,
# then everywhere else
2017-08-12 02:39:55 +02:00
sys.path.insert(1, gajim_root)
sys.path.insert(1, gajim_root + '/test/lib')
2008-06-12 05:56:30 +02:00
# a temporary version of ~/.gajim for testing
configdir = gajim_root + '/test/tmp'
2010-08-27 11:47:38 +02:00
# plugins config dir
pluginsconfigdir = configdir + '/pluginsconfig'
2008-06-12 05:56:30 +02:00
# define _ for i18n
2016-10-10 15:22:51 +02:00
import builtins
builtins._ = lambda x: x
2008-06-12 05:56:30 +02:00
def setup_env():
# wipe config directory
if os.path.isdir(configdir):
import shutil
shutil.rmtree(configdir)
2008-06-12 05:56:30 +02:00
os.mkdir(configdir)
2010-08-27 11:47:38 +02:00
os.mkdir(pluginsconfigdir)
2008-06-12 05:56:30 +02:00
2017-06-13 23:58:06 +02:00
import gajim.common.configpaths
gajim.common.configpaths.gajimpaths.init(configdir)
2008-06-12 05:56:30 +02:00
# for some reason gajim.common.app needs to be imported before xmpppy?
from gajim.common import app
2008-06-12 05:56:30 +02:00
import logging
logging.basicConfig()
app.DATA_DIR = gajim_root + '/data'
app.use_x = use_x
2008-06-29 07:25:59 +02:00
if use_x:
2017-08-12 02:39:55 +02:00
from gajim import gtkgui_helpers
gtkgui_helpers.GUI_DIR = gajim_root + '/data/gui'
2017-06-13 23:58:06 +02:00
from gajim.gajim import GajimApplication
app.app = GajimApplication()