How to do it...

In the following steps, we will explore creating some testable stories with Lettuce, and wiring them to runnable Python code:

  1. Create a new folder called recipe32 to contain all the files in this recipe.
  2. Create a file named recipe32.feature to capture our story. Write the top-level description of our new feature, based on our shopping cart:
Feature: Shopping cart As a shopper   I want to load up items in my cart   So that I can check out and pay for them
  1. Let's first create a scenario that captures the behavior of the cart when it's empty:
       Scenario: Empty cart            Given an empty cart            Then looking up the fifth item causes an error            And looking up a negative price causes an error            And the price with no taxes is $0.00 And the price ...

Get Python Testing Cookbook. now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.