Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ Let's look at a concrete example; let's say you have a class ``Wallet`` that has

# contents of wallet.py

import dataclass
from dataclasses import dataclass

@dataclass
class Wallet:
Expand All @@ -1287,6 +1287,7 @@ You can use pytest-factoryboy to automatically create model fixtures for this cl
class Meta:
model = Wallet

verified = False
amount_eur = 0
amount_usd = 0
amount_gbp = 0
Expand All @@ -1305,9 +1306,7 @@ Now we can define a function ``generate_wallet_steps(...)`` that creates the ste
import re
from dataclasses import fields

import factory
import pytest
from pytest_bdd import given, when, then, scenarios, parsers
from pytest_bdd import given, then, parsers


def generate_wallet_steps(model_name="wallet", stacklevel=1):
Expand Down Expand Up @@ -1338,7 +1337,7 @@ Now we can define a function ``generate_wallet_steps(...)`` that creates the ste
parsers.parse(f"I should have {{value:d}} {currency.upper()} in my {human_name}"),
stacklevel=stacklevel,
)
def _(value: int, _currency=currency, _model_name=model_name) -> None:
def _(request, value: int, _currency=currency, _model_name=model_name) -> None:
wallet = request.getfixturevalue(_model_name)
assert getattr(wallet, f"amount_{_currency}") == value

Expand Down
Loading