Skip to content

Prepare tests for upcoming twisted version#387

Merged
jelmer merged 1 commit intotesting-cabal:masterfrom
arkamar:fix-for-upcoming-twisted
Jul 1, 2024
Merged

Prepare tests for upcoming twisted version#387
jelmer merged 1 commit intotesting-cabal:masterfrom
arkamar:fix-for-upcoming-twisted

Conversation

@arkamar
Copy link
Copy Markdown
Contributor

@arkamar arkamar commented Jul 1, 2024

Current twisted trunk (twisted/twisted@49a649b) breaks two tests in the twistedsupport test suite, see the error log below. I was able to bisect the braking commit twisted/twisted@1269e56 introduced in PR twisted/twisted#12207. The mainLoop newly logs Main loop terminated. message even on exception, see twisted/twisted@1269e56#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)

@jelmer jelmer enabled auto-merge July 1, 2024 09:32
auto-merge was automatically disabled July 1, 2024 09:51

Head branch was pushed to by a user without write access

@arkamar arkamar force-pushed the fix-for-upcoming-twisted branch from 004b2ad to 6ad79b3 Compare July 1, 2024 09:51
@arkamar
Copy link
Copy Markdown
Contributor Author

arkamar commented Jul 1, 2024

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

@jelmer jelmer enabled auto-merge July 1, 2024 10:10
Twisted recently changed behavior of logger on failures [1]. It newly
logs the `Main loop terminated.` even on exceptions, which breaks two
test in twistedsupport test suite. This hack attempts to address the
upcoming issue.

[1] twisted/twisted#12207
auto-merge was automatically disabled July 1, 2024 11:24

Head branch was pushed to by a user without write access

@arkamar arkamar force-pushed the fix-for-upcoming-twisted branch from 6ad79b3 to 5b8cb64 Compare July 1, 2024 11:24
@arkamar
Copy link
Copy Markdown
Contributor Author

arkamar commented Jul 1, 2024

@jelmer jelmer enabled auto-merge July 1, 2024 12:11
@jelmer jelmer merged commit cdb1f3e into testing-cabal:master Jul 1, 2024
@arkamar
Copy link
Copy Markdown
Contributor Author

arkamar commented Jul 1, 2024

@jelmer thanks!

@arkamar arkamar deleted the fix-for-upcoming-twisted branch July 1, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants