Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install webtestrecorder

How to install WebTestRecorder

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install webtestrecorder
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.1 Available View build log
0.1 Failed View build log
Windows (64-bit)
0.1.1 Available View build log
0.1 Failed View build log
Mac OS X (10.5+)
0.1.1 Available View build log
0.1 Failed View build log
Linux (32-bit)
0.1.1 Available View build log
0.1 Failed View build log
Linux (64-bit)
0.1.1 Available View build log
0.1 Failed View build log
 
Author
License
MIT
Lastest release
version 0.1.1 on Nov 11th, 2011

This package lets you record all the requests and responses of an application, and then create a doctest from that. (There's no real reason it couldn't be a unit test... just haven't written that yet.)

The recorder is a piece of middleware. You use it like this:

from webtestrecorder import record_file

app = ... instantiate app ...
app = record_file(app, '/tmp/record.txt')

All requests and responses will be written to this file. You can read them out like so:

from webtestrecorder import get_records

records = get_records(open('/tmp/record.txt', 'rb'))

records is a list of requests, and each request has a .response attribute. You can then create a test:

from webtestrecorder import write_doctest

write_doctest(records, open('/tmp/doctest.txt', 'wb'))

You can also use this like a shell script:

$ python -m webtestrecorder < /tmp/record.txt > /tmp/doctest.txt

Apache Logs

You can read requests and responses from Apache logs via webtestrecorder.apachelog.parse_apache_log(). A constraint of this is that request bodies won't be present, and responses just have a status code and Content-Length, the Content-Type is unknown and the body is padded with null bytes.

Rerunning requests

The module webtestrecorder.http can take a list of requests/responses and send them to a server, effectively replaying requests. This is also a command-line program usable like:

$ python -m webtestrecorder.http apache_access.log --host localhost:8000

You can filter or rewrite these requests with a custom filter function. See python -m webtestrecorder.http -h for more.

News

0.1.1
  • Packaging fixes
0.1
  • Initial release

Subscribe to package updates

Last updated Nov 11th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.