[PATCH 03/13] Only use system subunit if it is sufficiently new.

Jelmer Vernooij jelmer at samba.org
Sat Nov 15 12:16:58 MST 2014


Change-Id: I14ba6ac114c35c4dcd3d151b07d24d74301f1181
Signed-off-by: Jelmer Vernooij <jelmer at samba.org>
---
 python/samba/__init__.py         | 2 +-
 python/samba/tests/subunitrun.py | 9 ++++++++-
 selftest/subunithelper.py        | 9 ++++++++-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/python/samba/__init__.py b/python/samba/__init__.py
index aa6bd3c..5d1aba7 100644
--- a/python/samba/__init__.py
+++ b/python/samba/__init__.py
@@ -33,7 +33,7 @@ def source_tree_topdir():
     for p in paths:
         topdir = os.path.normpath(os.path.join(os.path.dirname(__file__), p))
         if os.path.exists(os.path.join(topdir, 'source4')):
-            return topdir
+            return os.path.abspath(topdir)
     raise RuntimeError("unable to find top level source directory")
 
 
diff --git a/python/samba/tests/subunitrun.py b/python/samba/tests/subunitrun.py
index 4134440..eaecd46 100755
--- a/python/samba/tests/subunitrun.py
+++ b/python/samba/tests/subunitrun.py
@@ -38,6 +38,13 @@ import optparse
 import samba
 import sys
 import samba.tests
+def check_subunit(mod):
+    try:
+        from subunit.run import TestProgram
+    except ImportError:
+        return False
+    else:
+        return True
 samba.ensure_external_module("subunit", "subunit/python")
 import subunit.run
 
@@ -54,7 +61,7 @@ class SubunitOptions(optparse.OptionGroup):
                   help='Specify a filename containing the test ids to use.')
 
 
-class TestProgram(subunit.run.TestProgram):
+class TestProgram(subunit.run.SubunitTestProgram):
 
     def __init__(self, module=None, args=None, opts=None):
         if args is None:
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index 826d220..bf967c8 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -21,7 +21,14 @@ import samba
 samba.ensure_external_module("mimeparse", "mimeparse")
 samba.ensure_external_module("extras", "extras")
 samba.ensure_external_module("testtools", "testtools")
-samba.ensure_external_module("subunit", "subunit/python")
+def check_subunit(mod):
+    try:
+        __import__("subunit.run.TestProgram")
+    except ImportError:
+        return False
+    else:
+        return True
+samba.ensure_external_module("subunit", "subunit/python", check_subunit)
 
 import re
 import sys
-- 
2.1.3



More information about the samba-technical mailing list