From: Rob van der Linde Date: Tue, 26 Sep 2023 11:01:06 +0000 (+1300) Subject: netcmd: tests: make _run a classmethod in SambaToolCmdTest X-Git-Tag: tevent-0.16.0~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16c19c470eedb914eb1a82406ed3e203a7618d23;p=thirdparty%2Fsamba.git netcmd: tests: make _run a classmethod in SambaToolCmdTest So that it can be called from setUpClass as well Signed-off-by: Rob van der Linde Reviewed-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/samba_tool/base.py b/python/samba/tests/samba_tool/base.py index 3098817869c..1864dfd560e 100644 --- a/python/samba/tests/samba_tool/base.py +++ b/python/samba/tests/samba_tool/base.py @@ -62,11 +62,12 @@ class SambaToolCmdTest(samba.tests.BlackboxTestCase): return SamDB(url=opts.H, session_info=system_session(), credentials=creds, lp=lp) - def _run(self, *argv): + @classmethod + def _run(cls, *argv): """run a samba-tool command""" cmd, args = cmd_sambatool()._resolve('samba-tool', *argv, - outf=self.stringIO(), - errf=self.stringIO()) + outf=cls.stringIO(), + errf=cls.stringIO()) result = cmd._run(*args) return (result, cmd.outf.getvalue(), cmd.errf.getvalue()) diff --git a/python/samba/tests/samba_tool/domain_auth_base.py b/python/samba/tests/samba_tool/domain_auth_base.py index 54dfd90c1eb..d949c516be1 100644 --- a/python/samba/tests/samba_tool/domain_auth_base.py +++ b/python/samba/tests/samba_tool/domain_auth_base.py @@ -121,10 +121,11 @@ class BaseAuthCmdTest(SambaToolCmdTest): if len(result) == 1: return result[0] - def _run(self, *argv): + @classmethod + def _run(cls, *argv): """Override _run, so we don't always have to pass host and creds.""" args = list(argv) - args.extend(["-H", self.host, self.creds]) + args.extend(["-H", cls.host, cls.creds]) return super()._run(*args) runcmd = _run diff --git a/python/samba/tests/samba_tool/domain_claim.py b/python/samba/tests/samba_tool/domain_claim.py index 60b1de04d7f..0ae61f34ae7 100644 --- a/python/samba/tests/samba_tool/domain_claim.py +++ b/python/samba/tests/samba_tool/domain_claim.py @@ -130,10 +130,11 @@ class ClaimCmdTestCase(SambaToolCmdTest): claim_types_dn.add_child("CN=Claim Types,CN=Claims Configuration") return claim_types_dn - def _run(self, *argv): + @classmethod + def _run(cls, *argv): """Override _run, so we don't always have to pass host and creds.""" args = list(argv) - args.extend(["-H", self.host, self.creds]) + args.extend(["-H", cls.host, cls.creds]) return super()._run(*args) runcmd = _run diff --git a/python/samba/tests/samba_tool/visualize.py b/python/samba/tests/samba_tool/visualize.py index 21f545b4125..41d318beb46 100644 --- a/python/samba/tests/samba_tool/visualize.py +++ b/python/samba/tests/samba_tool/visualize.py @@ -150,9 +150,10 @@ class SambaToolVisualizeLdif(SambaToolCmdTest): '--color=no', '-S') self.assertCmdSuccess(result, monochrome, err) self.assert_colour(monochrome, False) + cls = self.__class__ try: - self.stringIO = StringIOThinksItIsATTY + cls.stringIO = StringIOThinksItIsATTY old_no_color = os.environ.pop('NO_COLOR', None) # First with no NO_COLOR env var. There should be colour. result, out, err = self.runsubcmd("visualize", "ntdsconn", @@ -204,7 +205,7 @@ class SambaToolVisualizeLdif(SambaToolCmdTest): self.assert_colour(out, is_colour, monochrome) finally: - self.stringIO = StringIO + cls.stringIO = StringIO if old_no_color is None: os.environ.pop('NO_COLOR', None) else: