]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python subunit: add dummy addDuration methods
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 8 Jan 2026 02:52:22 +0000 (15:52 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 15 Jan 2026 01:48:37 +0000 (01:48 +0000)
preventing this message:

/usr/lib/python3.12/unittest/case.py:580: RuntimeWarning: TestResult has no addDuration method
  warnings.warn("TestResult has no addDuration method",

as far as I can tell we have no real use for addDuration, since we
already measure time in other ways.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
python/samba/subunit/run.py
selftest/subunithelper.py

index dc3f9316fcbeff23671692c7392579afac19893c..39fbfdb09fca7ed4b1a22f27ab270060b9506466 100755 (executable)
@@ -81,6 +81,9 @@ class TestProtocolClient(unittest.TestResult):
         self._stream.write("test: " + test.id() + "\n")
         self._stream.flush()
 
+    def addDuration(self, *args):
+        pass
+
     def stopTest(self, test):
         """Mark a test as having finished its test run."""
         super().stopTest(test)
@@ -454,6 +457,9 @@ class AutoTimingTestResultDecorator(HookedTestResultDecorator):
         self._time = a_datetime
         return self.decorated.time(a_datetime)
 
+    def addDuration(self, *args):
+        pass
+
 
 class SubunitTestRunner(object):
 
index 490e77855230104e4e4c6633a7efcf12b8997e50..4e1c1752f05e0581f789b91b69063ac140048862 100644 (file)
@@ -42,6 +42,9 @@ VALID_RESULTS = set(['success', 'successful', 'failure', 'fail', 'skip',
 
 class TestsuiteEnabledTestResult(unittest.TestResult):
 
+    def addDuration(self, *args):
+        pass
+
     def start_testsuite(self, name):
         raise NotImplementedError(self.start_testsuite)
 
@@ -305,6 +308,9 @@ class FilterOps(unittest.TestResult):
     def _add_prefix(self, test):
         return subunit.RemotedTestCase(self.prefix + test.id() + self.suffix)
 
+    def addDuration(self, *args):
+        pass
+
     def addError(self, test, err=None):
         test = self._add_prefix(test)
         self.error_added += 1