Currently, building without this patch in Python 3.13 and 3.14 lead to:
testtools.testresult.real._StringException: Traceback (most recent call last):
File "/usr/lib/python3.13/unittest/mock.py", line 1432, in patched
return func(*newargs, **newkeywargs)
File "/build/python-oslo.log-0fVnL2/python-oslo.log-8.3.0/oslo_log/tests/unit/test_log.py", line 184, in test_rotate_log
self.assertEqual(self.log_handlers[0], handler_mock.return_value)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 438, in assertEqual
self.assertThat(observed, matcher, message)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 587, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = <StreamHandler <stdout> (NOTSET)>
actual = <MagicMock name='RotatingFileHandler()' id='140703819264896'>
3 tests are affected with this issue. This is because the cached handler
reference from setUp() becomes stale after _setup_logging_from_conf()
runs with active mocks. This patch fixes this by fetching a new log handler.
In addition, we fix some typing errors that are highlighted by recent
mypy versions.
Signed-off-by: Thomas Goirand <zigo@debian.org>
Co-authored-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
Assisted-By: Infomaniak Euria
Change-Id: I655b0f7c9e64206c63a32b11cb9da2cfe18a8320