From 6de9d878b5f63e5b5ac7f8b5dd2ca50e4ba8fa1a Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Sat, 21 Jul 2018 12:05:15 +0300 Subject: [PATCH] python/samba/tests: make sure samba.tests can be imported without SamDB MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We are using samba.tests Python module __init__.py file as a catch-all for all types of helpers. Some of these helpers are only usable with Samba AD DC targets. When SamDB is not available in a non-Samba AD DC target, provide a dummy replacement that simply returns None. This allows to complete initialization for non-Samba AD DC target tests which do not use connect_samdb() helper. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13542 Signed-off-by: Alexander Bokovoy Reviewed-by: Guenther Deschner Autobuild-User(master): Günther Deschner Autobuild-Date(master): Mon Jul 23 19:36:56 CEST 2018 on sn-devel-144 --- python/samba/tests/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 1d507102095..dcee691e6e9 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -38,7 +38,12 @@ import samba.dcerpc.base from samba.compat import PY3, text_type from samba.compat import string_types from random import randint -from samba.samdb import SamDB +try: + from samba.samdb import SamDB +except ImportError: + # We are built without samdb support, + # imitate it so that connect_samdb() can recover + SamDB = lambda *x: None import samba.ndr import samba.dcerpc.dcerpc import samba.dcerpc.epmapper -- 2.11.4.GIT