summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRob van der Linde <rob@catalyst.net.nz>2023-09-27 00:01:06 +1300
committerAndrew Bartlett <abartlet@samba.org>2023-09-29 02:18:34 +0000
commit16c19c470eedb914eb1a82406ed3e203a7618d23 (patch)
tree58e3a0b4800531fb88c651397b0f5000717ebc40 /python
parent71c191ca9fc8c836609f579de78678711e1ed034 (diff)
downloadsamba-16c19c470eedb914eb1a82406ed3e203a7618d23.tar.gz
samba-16c19c470eedb914eb1a82406ed3e203a7618d23.tar.bz2
samba-16c19c470eedb914eb1a82406ed3e203a7618d23.zip
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 <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/base.py7
-rw-r--r--python/samba/tests/samba_tool/domain_auth_base.py5
-rw-r--r--python/samba/tests/samba_tool/domain_claim.py5
-rw-r--r--python/samba/tests/samba_tool/visualize.py5
4 files changed, 13 insertions, 9 deletions
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: