Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: address __eq__ checking [APE-1178] #1534

Merged
merged 2 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ape/api/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def __eq__(self, other: object) -> bool:
try:
return convert(self, AddressType) == convert(other, AddressType)
except ConversionError:
return False
# Check other __eq__
return NotImplemented

def __dir__(self) -> List[str]:
"""
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/test_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

from ape.api.address import BaseAddress
from ape.types import AddressType


@pytest.fixture
def custom_address(zero_address):
class MyAddress(BaseAddress):
@property
def address(self) -> AddressType:
return zero_address

return MyAddress()


def test_eq(zero_address, custom_address):
assert custom_address == zero_address
assert zero_address == custom_address


def test_contains_in_list(zero_address, custom_address):
assert zero_address in [custom_address]
assert custom_address in [zero_address]