O'Reilly logo

Python Testing Cookbook. by Bhaskar N. Das, Greg L. Turnquist

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required