diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:21:24 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:21:24 +0900 |
commit | c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3 (patch) | |
tree | 1436172370a45714687122f914354ad167a2f528 /tests/common.py | |
parent | f7d643cbb2184346b6f8d26091eb7eb38c6bbfe1 (diff) | |
download | pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.tar.gz pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.tar.bz2 pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.zip |
Tizen 2.1 basesubmit/tizen_2.1/20130425.060530submit/tizen_2.1/20130424.235900submit/tizen/20130517.051955accepted/tizen_2.1/20130425.021253accepted/tizen/20130520.1018302.1b_releasetizen_2.1
Diffstat (limited to 'tests/common.py')
-rw-r--r-- | tests/common.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/common.py b/tests/common.py new file mode 100644 index 0000000..a6fa73d --- /dev/null +++ b/tests/common.py @@ -0,0 +1,48 @@ +import os +import sys + +def importModules(buildDir, srcDir): + # Be very careful when you change this code, it's + # fragile and the order is really significant + + sys.path.insert(0, srcDir) + sys.path.insert(0, buildDir) + sys.path.insert(0, os.path.join(buildDir, 'glib')) + sys.path.insert(0, os.path.join(buildDir, 'gobject')) + sys.path.insert(0, os.path.join(buildDir, 'gio')) + + # testhelper + sys.path.insert(0, os.path.join(buildDir, 'tests')) + sys.argv.append('--g-fatal-warnings') + + testhelper = importModule('testhelper', '.') + glib = importModule('glib', buildDir, 'glib') + gobject = importModule('gobject', buildDir, 'gobject') + gio = importModule('gio', buildDir, 'gio') + + globals().update(locals()) + + os.environ['PYGTK_USE_GIL_STATE_API'] = '' + gobject.threads_init() + +def importModule(module, directory, name=None): + global isDistCheck + + origName = module + if not name: + name = module + '.la' + + try: + obj = __import__(module, {}, {}, '') + except ImportError, e: + raise SystemExit('%s could not be imported: %s' % (origName, e)) + + location = obj.__file__ + + current = os.getcwd() + expected = os.path.abspath(os.path.join(current, location)) + current = os.path.abspath(location) + if current != expected: + raise AssertionError('module %s imported from wrong location. Expected %s, got %s' % ( + module, expected, current)) + return obj |