O'Reilly logo

Python Testing Cookbook by 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

Using Should DSL to write succinct assertions with Lettuce

Lettuce (http://lettuce.it) is a BDD tool built for Python.

The Should DSL (http://www.should-dsl.info) provides a simpler way to write assertions for Thens.

This recipe shows how to install Lettuce and Should DSL. Then, we will write a test story. Finally, we will wire it into our shopping cart application using the Should DSL to exercise our code.

Getting ready

For this recipe, we will be using the shopping cart application shown at the beginning of this chapter. We also need to install Lettuce and its dependencies:

  • Install lettuce by typing pip install lettuce
  • Install Should DSL by typing pip install should_dsl

How to do it...

With the following steps, we will use the Should DSL to write more ...

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