[PATCH 11/13] Add samba.subunit module, which takes care of setting up python paths.
Jelmer Vernooij
jelmer at samba.org
Sat Nov 15 12:17:06 MST 2014
Change-Id: Ia03a8642b2724a0e770a85fc705eb03c3e018487
Signed-off-by: Jelmer Vernooij <jelmer at samba.org>
---
python/samba/subunit.py | 33 +++++++++++++++++++++++++++++++++
python/samba/tests/subunitrun.py | 10 +---------
selftest/subunithelper.py | 12 +-----------
3 files changed, 35 insertions(+), 20 deletions(-)
create mode 100644 python/samba/subunit.py
diff --git a/python/samba/subunit.py b/python/samba/subunit.py
new file mode 100644
index 0000000..5c13299
--- /dev/null
+++ b/python/samba/subunit.py
@@ -0,0 +1,33 @@
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2009-2014
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""Samba-specific functions for using subunit."""
+
+__docformat__ = "restructuredText"
+
+import samba
+samba.ensure_third_party_module("mimeparse", "mimeparse")
+samba.ensure_third_party_module("extras", "python-extras")
+samba.ensure_third_party_module("testtools", "testtools")
+def check_subunit(mod):
+ try:
+ __import__("subunit.run.TestProgram")
+ except ImportError:
+ return False
+ else:
+ return True
+samba.ensure_third_party_module("subunit", "subunit/python", check_subunit)
diff --git a/python/samba/tests/subunitrun.py b/python/samba/tests/subunitrun.py
index ec54db4..581a4e4 100755
--- a/python/samba/tests/subunitrun.py
+++ b/python/samba/tests/subunitrun.py
@@ -37,15 +37,7 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
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_third_party_module("subunit", "subunit/python", check_subunit)
+import samba.subunit
import subunit.run
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index 2ebb217..d87ded5 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -18,17 +18,7 @@
__all__ = ['parse_results']
import samba
-samba.ensure_third_party_module("mimeparse", "mimeparse")
-samba.ensure_third_party_module("extras", "python-extras")
-samba.ensure_third_party_module("testtools", "testtools")
-def check_subunit(mod):
- try:
- __import__("subunit.run.TestProgram")
- except ImportError:
- return False
- else:
- return True
-samba.ensure_third_party_module("subunit", "subunit/python", check_subunit)
+import samba.subunit
import re
import sys
--
2.1.3
More information about the samba-technical
mailing list