| 1 | class HasStr: |
| 2 | def __str__(self): |
| 3 | return 'This is my __str__ method' |
| 4 | |
| 5 | class DoesNotHaveStr: |
| 6 | def __init__(self): |
| 7 | pass |
| 8 | |
| 9 | class HasToStringWithArg: |
| 10 | def toString(self, arg): |
| 11 | return 'weird' |
| 12 | |
| 13 | class HasHashCodeWithArg: |
| 14 | def hashCode(self, arg): |
| 15 | return 0 |
| 16 | |
| 17 | def __hash__(self): |
| 18 | return 1 |
| 19 | |
| 20 | class HasHashNegativeOne: |
| 21 | def __hash__(self): |
| 22 | return -1 |
| 23 | |
| 24 | class HasEqualsWithoutArg: |
| 25 | def equals(self): |
| 26 | return True |
| 27 | |
| 28 | class EqAlwaysFalse: |
| 29 | def __eq__(self, other): |
| 30 | return False |
| 31 | |
| 32 | class EqAlwaysTrue: |
| 33 | def __eq__(self, other): |
| 34 | return True |
| 35 | |
| 36 | class NoEqDefined: |
| 37 | def __init__(self): |
| 38 | pass |
| 39 | |
| 40 | class ProxyAsArgument: |
| 41 | def self_is_other(self, other): |
| 42 | return self is other |
| 43 | |
| 44 | class ThrowsException: |
| 45 | def __hash__(self): |
| 46 | raise Exception('this __hash__ always raises Exception') |
| 47 | |
| 48 | def __str__(self): |
| 49 | raise Exception('this __str__ always raises Exception') |
| 50 | |
| 51 | def __eq__(self, other): |
| 52 | raise Exception('this __eq__ always raises Exception') |
| 53 | |
| 54 | class NonBooleanEq: |
| 55 | def __eq__(self, other): |
| 56 | if self is other: |
| 57 | return 1 |
| 58 | return 0 |