Whole file

hamcrest/PyHamcrest

The author described this change as Ordered comparison matchers should fail for incomparable types. Fix for #185. It counts as a record because the check below fails on the code as it stood at cbc509573 and passes on 78e99b0eb, with nothing else changed between the two runs.

Fix saved2022-03-03
Sharing licenceBSD-3-Clause · LICENSE.txt
Change size+4 1

What the code was meant to do, written into the code itself as a save note

Ordered comparison matchers should fail for incomparable types. Fix for #185

The change

2222 self.comparison_description = comparison_description
2323
2424 def _matches(self, item: Any) -> bool:
25- return self.comparison_function(item, self.value)
25+ try:
26+ return self.comparison_function(item, self.value)
27+ except TypeError:
28+ return False
2629
2730 def describe_to(self, description: Description) -> None:
2831 description.append_text("a value ").append_text(self.comparison_description).append_text(

The check that tells the two apart

failpass·tests/hamcrest_unit_test/collection/issequence_containinginanyorder_test.py::IsConcreteSequenceContainingInAnyOrderTest::testIncomparableTypesInNestedMatcher

Check file tests/hamcrest_unit_test/collection/issequence_containinginanyorder_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itcbc50957373d3ce921477807ea0a24da44310e33
Broken version dated2022-03-03
Modulehamcrest.library.number.ordering_comparison
Units changedOrderingComparison
Fingerprint61b8af65978602ca
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in hamcrest/PyHamcrest