summaryrefslogtreecommitdiff
path: root/tests/functional/r/regression/regression_6531_crash_index_error.py
blob: cfcfd8e6096980b1c0433f63791ba5a237e1d2bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Regression test for https://github.com/pylint-dev/pylint/issues/6531."""

# pylint: disable=missing-docstring, redefined-outer-name

import pytest


class Wallet:
    def __init__(self):
        self.balance = 0

    def add_cash(self, earned):
        self.balance += earned

    def spend_cash(self, spent):
        self.balance -= spent

@pytest.fixture
def my_wallet():
    '''Returns a Wallet instance with a zero balance'''
    return Wallet()

@pytest.mark.parametrize("earned,spent,expected", [
    (30, 10, 20),
    (20, 2, 18),
])
def test_transactions(my_wallet, earned, spent, expected):
    my_wallet.add_cash(earned)
    my_wallet.spend_cash(spent)
    assert my_wallet.balance == expected