testing-cabal / testtools

Testtools - tasteful testing for python
https://testtools.readthedocs.io/en/latest/
Other
94 stars 88 forks source link

Prepare tests for upcoming twisted version #387

Closed arkamar closed 2 months ago

arkamar commented 2 months ago

Current twisted trunk (https://github.com/twisted/twisted/commit/49a649b6d8ead04dbe774918e660505998859efc) breaks two tests in the twistedsupport test suite, see the error log below. I was able to bisect the braking commit https://github.com/twisted/twisted/commit/1269e566ccffa5bba3006248e36ff09086fdccbe introduced in PR https://github.com/twisted/twisted/pull/12207. The mainLoop newly logs Main loop terminated. message even on exception, see https://github.com/twisted/twisted/commit/1269e566ccffa5bba3006248e36ff09086fdccbe#diff-c6cc886d2bcab963daa7b561a036e0bea05ef01ef3351f66489f1fffea94c1eaR702-R710 but both affected tests expect only foo.

This hackish PR tries to address the upcoming issue.

======================================================================
FAIL: testtools.tests.twistedsupport.test_runtest.TestAsynchronousDeferredRunTest.test_log_in_details
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/testtools/testtools/tests/twistedsupport/test_runtest.py", line 743, in test_log_in_details
    self.assertThat(
  File "/root/testtools/testtools/testcase.py", line 509, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: Differences: [
Differences: [
Differences: {
  'twisted-log': '''\
2024-07-01 07:08:06+0000 [-] foo
2024-07-01 07:08:06+0000 [-] Main loop terminated.
''' does not end with '''\
 foo
'''.: after <function <lambda>> on <Content type=text/plain; charset="utf8", value=b'2024-07-01 07:08:06+0000 [-] foo\n2024-07-01 07:08:06+0000 [-] Main loop terminated.\n'>,
}
]
]
======================================================================
FAIL: testtools.tests.twistedsupport.test_runtest.TestAsynchronousDeferredRunTest.test_log_to_twisted
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/testtools/testtools/tests/twistedsupport/test_runtest.py", line 792, in test_log_to_twisted
    self.assertThat(
  File "/root/testtools/testtools/testcase.py", line 509, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: Differences: [
len([{'system': '-', 'message': ('foo',), 'time': 1719817686.7797003, 'isError': 0, 'log_time': 1719817686.7797003, 'log_text': 'foo', 'log_format': '{log_text}', 'log_level': <LogLevel=info>, 'log_namespace': 'log_legacy', 'log_system': '-', 'format': '%(log_legacy)s', 'log_legacy': <twisted.logger._stdlib.StringifiableFromEvent object at 0x7f5393e0e5c0>}, {'log_logger': <Logger 'twisted.internet.base'>, 'log_level': <LogLevel=info>, 'log_namespace': 'twisted.internet.base', 'log_source': None, 'log_format': 'Main loop terminated.', 'log_time': 1719817686.7798698, 'message': (), 'time': 1719817686.7798698, 'system': '-', 'format': '%(log_legacy)s', 'log_legacy': <twisted.logger._stdlib.StringifiableFromEvent object at 0x7f5393e0d600>, 'isError': 0}]) != 1: Length mismatch
]

Ran 2627 tests in 0.913s
FAILED (failures=2)
arkamar commented 2 months ago

FP with removed EndsWith import in order to pass ruff check: https://github.com/testing-cabal/testtools/actions/runs/9741013453/job/26881713355#step:6:12

arkamar commented 2 months ago

FP with ruff format change in order to address https://github.com/testing-cabal/testtools/actions/runs/9742062227/job/26883395925#step:7:12

arkamar commented 2 months ago

@jelmer thanks!