Skip to content

Commit

Permalink
[unittest] Define _addDuration method to suppress 3.12 warnings canon…
Browse files Browse the repository at this point in the history
…ical#829 (canonical#829)

Change:
python/cpython@d88087e

This essentially suppresses the warnings:
RuntimeWarning: TestResult has no addDuration method\n  warnings.warn("TestResult has no addDuration method")

Signed-off-by: Ponnuvel Palaniyappan <[email protected]>
  • Loading branch information
pponnuvel authored Apr 29, 2024
1 parent 10b04e1 commit 7ebf6ef
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ def setUp(self):
else:
LoggingManager().start(level=logging.WARNING)

def _addDuration(self, *args, **kwargs): # For Python >= 3.12
""" Python 3.12 needs subclasses of unittest.TestCase to implement
this in order to record times and execute any cleanup actions once
a test completes regardless of success. Otherwise it emits a warning.
This generic implementation helps suppress it and possibly others in
the future. """

def tearDown(self):
LoggingManager().stop()
HotSOSConfig.reset()
Expand Down

0 comments on commit 7ebf6ef

Please sign in to comment.