[pygobject] Clean up sys.path handling in tests



commit c7c95a795eee499373499ea5b771447746317bfb
Author: Simon Feltman <s feltman gmail com>
Date:   Thu Aug 23 06:03:09 2012 +0200

    Clean up sys.path handling in tests
    
    Only set sys.path once in runtests.py, not in the individual test modules. This
    reduces hidden dependencies between tests by building up a run order dependent
    search path, and also makes it easier in the future to run the tests against
    the installed system libraries.
    
    Side issue in https://bugzilla.gnome.org/show_bug.cgi?id=680913

 tests/runtests-windows.py |    6 +++++-
 tests/runtests.py         |    3 +++
 tests/test_everything.py  |    1 -
 tests/test_gdbus.py       |    3 ---
 tests/test_overrides.py   |    3 ---
 tests/test_pygtkcompat.py |    3 ---
 6 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/tests/runtests-windows.py b/tests/runtests-windows.py
index ae81202..d004603 100644
--- a/tests/runtests-windows.py
+++ b/tests/runtests-windows.py
@@ -7,8 +7,12 @@ import sys
 import glob
 import unittest
 
+mydir = os.path.dirname(os.path.abspath(__file__))
+# The ordering of sys.path should be ['.../pyobject', '.../pygobject/tests']
+sys.path.insert(0, mydir)
+sys.path.insert(0, os.path.dirname(mydir))
+
 os.environ['PYGTK_USE_GIL_STATE_API'] = ''
-sys.path.insert(0, os.path.dirname(__file__))
 sys.argv.append('--g-fatal-warnings')
 
 from gi.repository import GObject
diff --git a/tests/runtests.py b/tests/runtests.py
index 2215196..b821c26 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -12,6 +12,9 @@ if '--help' in sys.argv:
     sys.exit(0)
 
 mydir = os.path.dirname(os.path.abspath(__file__))
+# The ordering of sys.path should be ['.../pyobject', '.../pygobject/tests']
+sys.path.insert(0, mydir)
+sys.path.insert(0, os.path.dirname(mydir))
 
 # force untranslated messages, as we check for them in some tests
 os.environ['LC_MESSAGES'] = 'C'
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 3cf98fa..e09b27a 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -5,7 +5,6 @@
 import unittest
 
 import sys
-sys.path.insert(0, "../")
 from sys import getrefcount
 
 import copy
diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py
index 3411e48..b129419 100644
--- a/tests/test_gdbus.py
+++ b/tests/test_gdbus.py
@@ -3,9 +3,6 @@
 
 import unittest
 
-import sys
-sys.path.insert(0, "../")
-
 from gi.repository import GObject
 from gi.repository import GLib
 from gi.repository import Gio
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 8665cec..0ad8295 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -3,9 +3,6 @@
 
 import unittest
 
-import sys
-sys.path.insert(0, "../")
-
 from compathelper import _long, _unicode, _bytes
 
 import gi.overrides as overrides
diff --git a/tests/test_pygtkcompat.py b/tests/test_pygtkcompat.py
index 926910b..5fabf2a 100644
--- a/tests/test_pygtkcompat.py
+++ b/tests/test_pygtkcompat.py
@@ -3,9 +3,6 @@
 
 import unittest
 
-import sys
-sys.path.insert(0, "../")
-
 from gi.repository import GLib
 
 try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]