Pragmatic Testing Framework for Python with BDD-style syntax and pluggable architecture
Acceptance-style scenarios that exercise a miniature checkout flow by composing setup, action, and assertion steps. Provide one class-oriented scenario for the successful path and two function-oriented scenarios for alternative outcomes. Each scenario should carry a human-readable subject string and keep per-scenario state that later steps can read.
{"latte": 3, "mug": 2} and the order requests ("latte", 2, 7) and ("mug", 1, 10). @test{"beans": 4} and the order requests ("beans", 2, 9). @test{"filters": 1} and the order requests ("filters", 3, 2). @test@generates
"""
Scenarios describing checkout outcomes for a tiny in-memory store.
At runtime, the scenario runner should discover:
- A class-based scenario with subject and step methods.
- Two function-style scenarios built with decorators, each exposing given/when/then steps.
"""
class CheckoutSuccessFlow:
subject: str # e.g., "Charge succeeds when items are in stock"
inventory: dict
order: list
events: list
charge_total: int
def given_stocked_items(self) -> None: ...
def when_reserving_and_charging(self) -> None: ...
def then_charge_is_recorded(self) -> None: ...
# Steps should:
# - Reserve items by decrementing inventory for the requested order.
# - Attempt a single payment equal to the sum of price * quantity.
# - Append descriptive strings to events for each step in sequence.
def payment_retry_flow():
"""
Function-style scenario:
- Given an order priced at 18 with sufficient stock.
- First payment attempt should fail with a recoverable error and be logged.
- A retry should succeed, setting the final charge total to 18.
- The then-step confirms both attempts were executed in order.
- Events track attempt outcomes, e.g., ["given beans", "when charge failed", "when charge succeeded", "then confirmed"].
"""
def out_of_stock_flow():
"""
Function-style scenario:
- Given an order that asks for more units than inventory allows.
- When step should detect depletion before any payment attempt.
- Then-step should surface a failure reason indicating which item is short.
- Events should only include the setup and the failure acknowledgement.
"""Scenario-based test DSL for structuring given/when/then workflows.
@satisfied-by
tessl i tessl/pypi-vedro@1.14.0docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10