Merge lp:~cjwatson/storm/fix-py311-tests into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 583
Proposed branch: lp:~cjwatson/storm/fix-py311-tests
Merge into: lp:storm
Diff against target: 22 lines (+12/-1)
1 file modified
storm/tests/event.py (+12/-1)
To merge this branch: bzr merge lp:~cjwatson/storm/fix-py311-tests
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+461676@code.launchpad.net

Commit message

Fix tests on Python 3.11.

Description of the change

Tests were failing as follows:

  ======================================================================
  ERROR: test_hook_unhook_emit (storm.tests.event.EventTest.test_hook_unhook_emit)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "storm/tests/mocker.py", line 101, in test_method_wrapper
      result = test_method()
               ^^^^^^^^^^^^^
    File "storm/tests/event.py", line 61, in test_hook_unhook_emit
      self.assertEqual(sorted(called1), [
                       ^^^^^^^^^^^^^^^
  TypeError: '<' not supported between instances of 'Marker' and 'Marker'

This seems to have been prompted by a change to the `list.sort` implementation in Python 3.11 that I somehow failed to notice before, but it's easily fixed by giving `Marker` a few trivial comparison methods.

To post a comment you must log in.
lp:~cjwatson/storm/fix-py311-tests updated
582. By Colin Watson

Fix tests on Python 3.11.

Tests were failing as follows:

  ======================================================================
  ERROR: test_hook_unhook_emit (storm.tests.event.EventTest.test_hook_unhook_emit)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "storm/tests/mocker.py", line 101, in test_method_wrapper
      result = test_method()
               ^^^^^^^^^^^^^
    File "storm/tests/event.py", line 61, in test_hook_unhook_emit
      self.assertEqual(sorted(called1), [
                       ^^^^^^^^^^^^^^^
  TypeError: '<' not supported between instances of 'Marker' and 'Marker'

This seems to have been prompted by a change to the `list.sort`
implementation in Python 3.11 that I somehow failed to notice before,
but it's easily fixed by giving `Marker` a few trivial comparison
methods.

Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'storm/tests/event.py'
--- storm/tests/event.py 2019-11-21 16:06:52 +0000
+++ storm/tests/event.py 2024-03-03 15:49:10 +0000
@@ -25,7 +25,18 @@
2525
2626
27class Marker(object):27class Marker(object):
28 pass28 def __eq__(self, other):
29 return self is other
30
31 def __lt__(self, other):
32 return False if self is other else NotImplemented
33
34 __gt__ = __lt__
35
36 def __le__(self, other):
37 return True if self is other else NotImplemented
38
39 __ge__ = __le__
2940
30marker = Marker()41marker = Marker()
3142

Subscribers

People subscribed via source and target branches

to status/vote changes: