O'Reilly logo

Python Testing Beginner's Guide by Daniel Arbuckle

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

Time for action - running Twill script strings

The second way to run a Twill script from inside Python code is to store the script in a string.

  1. Open up an interactive Python interpreter and type the following commands:
    >>> from twill.parse import execute_string
    >>> execute_string("""
    ... go http://slashdot.org/
    ... find this_does_not_exist
    ... """, no_reset = False)
    
    
  2. The result will be just the same as when we executed a file containing those commands.

Note

Notice the no_reset = False parameter that we passed to execute_string. We need that because if we leave it out, Twill will assume that all of our calls to execute_string should be executed, as if they were all part of the same browser session. We don't want that because we want our tests to be ...

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