# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1279114761 -7200 # Node ID 95abc4cfc78fafe08f5f6d374bf9d4cde73b30ad # Parent d2ef7220a079fc913ee3b4affd55b7d0507871ae tests: improve import logic We already had some logic some logic to make us import the local modules, but it failed under certain circumstances. I suspect that it had to do with absolute vs. relative paths. Regardless of what the root cause was, this fixes it. diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 --- a/tests/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import imp, os, sys - -sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) diff --git a/tests/run.py b/tests/run.py --- a/tests/run.py +++ b/tests/run.py @@ -4,7 +4,6 @@ import sys import unittest def tests(): - import test_util import test_binaryfiles import test_diff import test_externals @@ -62,19 +61,21 @@ if __name__ == '__main__': else: testargs = {'descriptions': 2} - # make sure our copy of hgsubversion gets imported sys.path.append(os.path.dirname(os.path.dirname(__file__))) if options.demandimport: from mercurial import demandimport demandimport.enable() + # make sure our copy of hgsubversion gets imported by loading test_util + import test_util + test_util.TestBase + # silence output when running outside nose import tempfile sys.stdout = tempfile.TemporaryFile() all = tests() - del all['test_util'] args = [i.split('.py')[0].replace('-', '_') for i in args] diff --git a/tests/test_diff.py b/tests/test_diff.py --- a/tests/test_diff.py +++ b/tests/test_diff.py @@ -1,7 +1,6 @@ import test_util import unittest -import tests from mercurial import ui diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -12,7 +12,8 @@ import tempfile import unittest import urllib -import __init__ +_rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, _rootdir) from mercurial import commands from mercurial import context