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
1=== modified file 'storm/tests/event.py'
2--- storm/tests/event.py 2019-11-21 16:06:52 +0000
3+++ storm/tests/event.py 2024-03-03 15:49:10 +0000
4@@ -25,7 +25,18 @@
5
6
7 class Marker(object):
8- pass
9+ def __eq__(self, other):
10+ return self is other
11+
12+ def __lt__(self, other):
13+ return False if self is other else NotImplemented
14+
15+ __gt__ = __lt__
16+
17+ def __le__(self, other):
18+ return True if self is other else NotImplemented
19+
20+ __ge__ = __le__
21
22 marker = Marker()
23

Subscribers

People subscribed via source and target branches

to status/vote changes: