From 4d3e89b06977362707ccb0d7f70311181b4e0da8 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 23 Aug 2012 07:38:54 -0400 Subject: removed relative imports from testsuite for py2.4 compat --- .../TestClient/TestTools/TestPOSIX/TestDevice.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py') diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py index 1130199b4..fb80991d7 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py @@ -1,12 +1,22 @@ import os +import sys import copy import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Device import * -from .Test__init import get_posix_object -from .Testbase import TestPOSIXTool -# python 2.5 can't import * from relative imports -from .....common import XI_NAMESPACE, XI, inPy3k, call, builtins, u, can_skip, \ + +# add all parent testsuite directories to sys.path to allow (most) +# relative imports in python 2.4 +path = os.path.dirname(__file__) +while path != "/": + if os.path.basename(path).lower().startswith("test"): + sys.path.append(path) + if os.path.basename(path) == "testsuite": + break + path = os.path.dirname(path) +from Test__init import get_posix_object +from Testbase import TestPOSIXTool +from common import XI_NAMESPACE, XI, inPy3k, call, builtins, u, can_skip, \ skip, skipIf, skipUnless, Bcfg2TestCase, DBModelTestCase, syncdb, \ patchIf, datastore -- cgit v1.2.3-1-g7c22