From: Douglas Bagnall Date: Tue, 18 Mar 2025 23:04:26 +0000 (+1300) Subject: python: make source_tree_topdir() test-only X-Git-Tag: tevent-0.17.0~446 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24fb3bb87449dd2d4e8df2b48637c59adf63022a;p=thirdparty%2Fsamba.git python: make source_tree_topdir() test-only Signed-off-by: Douglas Bagnall Reviewed-by: Ralph Boehme --- diff --git a/python/samba/__init__.py b/python/samba/__init__.py index 6bdf65d923d..dd3a44ad350 100644 --- a/python/samba/__init__.py +++ b/python/samba/__init__.py @@ -31,16 +31,6 @@ from samba import _glue from samba._ldb import Ldb as _Ldb -def source_tree_topdir(): - """Return the top level source directory.""" - paths = ["../../..", "../../../.."] - 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 - raise RuntimeError("unable to find top level source directory") - - class Ldb(_Ldb): """Simple Samba-specific LDB subclass that takes care of setting up the modules dir, credentials pointers, etc. diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 6af0940e8e4..0374dfa65f6 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -65,6 +65,16 @@ LDB_ERR_LUT = {v: k for k, v in vars(ldb).items() if k.startswith('ERR_')} RE_CAMELCASE = re.compile(r"([_\-])+") +def source_tree_topdir(): + """Return the top level source directory.""" + paths = ["../../..", "../../../.."] + 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 + raise RuntimeError("unable to find top level source directory") + + def ldb_err(v): if isinstance(v, ldb.LdbError): v = v.args[0] diff --git a/python/samba/tests/dns_forwarder.py b/python/samba/tests/dns_forwarder.py index 86b553e53e4..3af8085a649 100644 --- a/python/samba/tests/dns_forwarder.py +++ b/python/samba/tests/dns_forwarder.py @@ -24,7 +24,7 @@ import time import errno import samba.ndr as ndr from samba import credentials -from samba.tests import TestCase +from samba.tests import TestCase, source_tree_topdir from samba.dcerpc import dns from samba.tests.subunitrun import SubunitOptions, TestProgram import samba.getopt as options @@ -170,7 +170,7 @@ class TestDnsForwarding(DNSTest): def start_toy_server(self, host, port, id): python = sys.executable p = subprocess.Popen([python, - os.path.join(samba.source_tree_topdir(), + os.path.join(source_tree_topdir(), 'python/samba/tests/' 'dns_forwarder_helpers/server.py'), host, str(port), id]) diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index 66189277260..e52a97ed629 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -240,7 +240,7 @@ class SmbDotConfTests(TestCase): finally: f.close() - self.topdir = os.path.abspath(samba.source_tree_topdir()) + self.topdir = os.path.abspath(samba.tests.source_tree_topdir()) try: self.documented = set(get_documented_parameters(self.topdir)) diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py index 3f1111f8002..3e3334be6ca 100644 --- a/python/samba/tests/samba_tool/gpo.py +++ b/python/samba/tests/samba_tool/gpo.py @@ -21,6 +21,7 @@ import os, pwd, grp import ldb import samba +from samba.tests import source_tree_topdir from samba.tests.samba_tool.base import SambaToolCmdTest import shutil from samba.netcmd.gpo import get_gpo_dn, get_gpo_info @@ -1879,7 +1880,7 @@ class GpoCmdTestCase(SambaToolCmdTest): except IndexError: self.fail("Failed to find GUID in output: %s" % out) - self.backup_path = os.path.join(samba.source_tree_topdir(), 'source4', + self.backup_path = os.path.join(source_tree_topdir(), 'source4', 'selftest', 'provisions', 'generalized-gpo-backup')