MCPcopy Index your code
hub / github.com/RustPython/RustPython / TrackComparison

Class TrackComparison

extra_tests/snippets/builtin_list.py:276–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274# Test that sorted() uses __lt__ (not __gt__) for comparisons.
275# Track which comparison method is actually called during sort.
276class TrackComparison:
277 lt_calls = 0
278 gt_calls = 0
279
280 def __init__(self, value):
281 self.value = value
282
283 def __lt__(self, other):
284 TrackComparison.lt_calls += 1
285 return self.value < other.value
286
287 def __gt__(self, other):
288 TrackComparison.gt_calls += 1
289 return self.value > other.value
290
291
292# Reset and test sorted()

Callers 1

builtin_list.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected