]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python/tests: Make helpful, stateless methods @classmethod and @staticmethod
authorAndrew Bartlett <abartlet@samba.org>
Wed, 14 Jun 2023 22:49:32 +0000 (10:49 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 14 Jun 2023 22:57:34 +0000 (22:57 +0000)
This allows them to be used in setUpClass in tests.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/__init__.py

index 101f5922a220f406a28c8b03f57ea69270decd12..f117d0b1341969281ef83f606af67878721690d4 100644 (file)
@@ -393,7 +393,8 @@ class BlackboxProcessError(Exception):
 class BlackboxTestCase(TestCaseInTempDir):
     """Base test case for blackbox tests."""
 
-    def _make_cmdline(self, line):
+    @staticmethod
+    def _make_cmdline(line):
         """Expand the called script into a fully resolved path in the bin
         directory."""
         if isinstance(line, list):
@@ -458,8 +459,9 @@ class BlackboxTestCase(TestCaseInTempDir):
     # where ret is the return code
     #       stdout is a string containing the commands stdout
     #       stderr is a string containing the commands stderr
-    def run_command(self, line):
-        line = self._make_cmdline(line)
+    @classmethod
+    def run_command(cls, line):
+        line = cls._make_cmdline(line)
         use_shell = not isinstance(line, list)
         p = subprocess.Popen(line,
                              stdout=subprocess.PIPE,