File: bdd_wallet.py

package info (click to toggle)
pytest 9.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,308 kB
  • sloc: python: 65,808; makefile: 45
file content (42 lines) | stat: -rw-r--r-- 681 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
37
38
39
40
41
42
# mypy: allow-untyped-defs
from __future__ import annotations

from pytest_bdd import given
from pytest_bdd import scenario
from pytest_bdd import then
from pytest_bdd import when

import pytest


@scenario("bdd_wallet.feature", "Buy fruits")
def test_publish():
    pass


@pytest.fixture
def wallet():
    class Wallet:
        amount = 0

    return Wallet()


@given("A wallet with 50")
def fill_wallet(wallet):
    wallet.amount = 50


@when("I buy some apples for 1")
def buy_apples(wallet):
    wallet.amount -= 1


@when("I buy some bananas for 2")
def buy_bananas(wallet):
    wallet.amount -= 2


@then("I have 47 left")
def check(wallet):
    assert wallet.amount == 47