Skip to content

Commit 925d2f8

Browse files
committed
fix: mypy cannot assign method
1 parent bf931bd commit 925d2f8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

tests/unit/test_gas_estimation.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ def mock_eth_account():
2727
) # 100k gas units
2828

2929
# Mock get_eth_balance to return a specific balance
30-
account.get_eth_balance = MagicMock(return_value=10**18) # 1 ETH
31-
32-
return account
30+
with patch.object(account, "get_eth_balance", return_value=10**18): # 1 ETH
31+
yield account
3332

3433

3534
@pytest.fixture
@@ -61,11 +60,10 @@ def test_can_transact_with_insufficient_funds(self, mock_eth_account):
6160
tx = TxParams({"to": "0xreceiver", "value": 0})
6261

6362
# Set balance to almost zero
64-
mock_eth_account.get_eth_balance = MagicMock(return_value=1000)
65-
66-
# Should raise InsufficientFundsError
67-
with pytest.raises(InsufficientFundsError) as exc_info:
68-
mock_eth_account.can_transact(tx=tx, block=True)
63+
with patch.object(mock_eth_account, "get_eth_balance", return_value=1000):
64+
# Should raise InsufficientFundsError
65+
with pytest.raises(InsufficientFundsError) as exc_info:
66+
mock_eth_account.can_transact(tx=tx, block=True)
6967

7068
assert exc_info.value.token_type == TokenType.GAS
7169

0 commit comments

Comments
 (0)