From: Douglas Bagnall Date: Thu, 8 Jan 2026 02:52:22 +0000 (+1300) Subject: python subunit: add dummy addDuration methods X-Git-Tag: tdb-1.4.15~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55c229966497425497ec3d621a37873370ea81f9;p=thirdparty%2Fsamba.git python subunit: add dummy addDuration methods 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 Reviewed-by: Gary Lockyer --- diff --git a/python/samba/subunit/run.py b/python/samba/subunit/run.py index dc3f9316fcb..39fbfdb09fc 100755 --- a/python/samba/subunit/run.py +++ b/python/samba/subunit/run.py @@ -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): diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 490e7785523..4e1c1752f05 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -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