사용자 도구

사이트 도구


python:pytest

문서의 이전 판입니다!


Python: pytest

기본 사용법1)

# test_wallet.py
 
@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
/var/www/html/data/pages/python/pytest.txt · 마지막으로 수정됨: 저자 127.0.0.1