Skip to content

Commit 64adbd5

Browse files
authored
fix(programmatic_step_generation): clean-up and fixes
wallet.py - changed: from dataclasses import dataclass - added: verified: bool wallet_factory.py - added: verified = False wallet_steps.py - removed: import pytest - removed: from pytest_bdd import when, scenarios - added: @then ... def _(request,
1 parent a1a4a00 commit 64adbd5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ Let's look at a concrete example; let's say you have a class ``Wallet`` that has
12601260
12611261
# contents of wallet.py
12621262
1263-
import dataclass
1263+
from dataclasses import dataclass
12641264
12651265
@dataclass
12661266
class Wallet:
@@ -1287,6 +1287,7 @@ You can use pytest-factoryboy to automatically create model fixtures for this cl
12871287
class Meta:
12881288
model = Wallet
12891289
1290+
verified = False
12901291
amount_eur = 0
12911292
amount_usd = 0
12921293
amount_gbp = 0
@@ -1305,9 +1306,7 @@ Now we can define a function ``generate_wallet_steps(...)`` that creates the ste
13051306
import re
13061307
from dataclasses import fields
13071308
1308-
import factory
1309-
import pytest
1310-
from pytest_bdd import given, when, then, scenarios, parsers
1309+
from pytest_bdd import given, then, parsers
13111310
13121311
13131312
def generate_wallet_steps(model_name="wallet", stacklevel=1):
@@ -1338,7 +1337,7 @@ Now we can define a function ``generate_wallet_steps(...)`` that creates the ste
13381337
parsers.parse(f"I should have {{value:d}} {currency.upper()} in my {human_name}"),
13391338
stacklevel=stacklevel,
13401339
)
1341-
def _(value: int, _currency=currency, _model_name=model_name) -> None:
1340+
def _(request, value: int, _currency=currency, _model_name=model_name) -> None:
13421341
wallet = request.getfixturevalue(_model_name)
13431342
assert getattr(wallet, f"amount_{_currency}") == value
13441343

0 commit comments

Comments
 (0)