Download benchmarks/reference/py-bank.py from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/reference/py-bank.py
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/reference/py-bank.py
-
curl -L -o py-bank.py https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/reference/py-bank.py
2.22 kB
| import pytest | |
| from solution import BankAccount, InsufficientFunds | |
| def acc(): | |
| return BankAccount("Ayşe", 100) | |
| def test_init_strips_owner_and_sets_balance(): | |
| a = BankAccount(" Ali ", 50, overdraft_limit=20) | |
| assert a.owner == "Ali" and a.balance == 50.0 and a.overdraft_limit == 20.0 | |
| def test_init_rejects_invalid(args): | |
| with pytest.raises(ValueError): | |
| BankAccount(*args) | |
| def test_deposit_increases_balance(acc): | |
| assert acc.deposit(25) == 125 | |
| assert acc.history == [("deposit", 25)] | |
| def test_deposit_rejects_non_positive(acc, amount): | |
| with pytest.raises(ValueError): | |
| acc.deposit(amount) | |
| def test_withdraw_within_balance(acc): | |
| assert acc.withdraw(40) == 60 | |
| def test_withdraw_uses_overdraft_up_to_limit(): | |
| a = BankAccount("Can", 10, overdraft_limit=50) | |
| assert a.withdraw(60) == -50 | |
| def test_withdraw_beyond_limit_raises(): | |
| a = BankAccount("Can", 10, overdraft_limit=50) | |
| with pytest.raises(InsufficientFunds): | |
| a.withdraw(60.01) | |
| def test_withdraw_rejects_non_positive(acc): | |
| with pytest.raises(ValueError): | |
| acc.withdraw(0) | |
| def test_transfer_moves_money(acc): | |
| other = BankAccount("Veli") | |
| acc.transfer(other, 30) | |
| assert (acc.balance, other.balance) == (70, 30) | |
| def test_transfer_to_self_rejected(acc): | |
| with pytest.raises(ValueError): | |
| acc.transfer(acc, 10) | |
| def test_interest_on_positive_balance(acc): | |
| assert acc.apply_interest(0.1) == 110 | |
| assert acc.history[-1] == ("interest", 10.0) | |
| def test_no_interest_on_negative_balance(): | |
| a = BankAccount("Can", 0, overdraft_limit=100) | |
| a.withdraw(50) | |
| assert a.apply_interest(0.5) == -50 | |
| def test_interest_rate_bounds(acc, rate): | |
| with pytest.raises(ValueError): | |
| acc.apply_interest(rate) | |
| def test_statement_lists_history(acc): | |
| acc.deposit(5) | |
| acc.withdraw(10) | |
| text = acc.statement() | |
| assert text.splitlines()[0] == "Hesap sahibi: Ayşe" | |
| assert "withdraw -10.00" in text | |
| assert text.endswith("Bakiye: 95.00") | |