Skip to content
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: 3 additions & 0 deletions bittensor/utils/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def __repr__(self):
return self.__str__()

def __eq__(self, other: Union[int, float, "Balance"]):
if other is None:
return False

if hasattr(other, "rao"):
return self.rao == other.rao
else:
Expand Down
9 changes: 9 additions & 0 deletions tests/unit_tests/bittensor_tests/test_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,12 @@ def test_balance_rfloordiv_other_not_balance(self, balance: Union[int, float], b
assert isinstance(quot_, Balance)
assert CLOSE_IN_VALUE(quot_.rao, 5) == rao2_ // rao_

@given(balance=valid_tao_numbers_strategy)
def test_balance_not_eq_none(self, balance: Union[int, float]):
balance_ = Balance(balance)
assert not balance_ == None

@given(balance=valid_tao_numbers_strategy)
def test_balance_neq_none(self, balance: Union[int, float]):
balance_ = Balance(balance)
assert balance_ != None