Aspen

A Python web framework that makes the most of the filesystem.
Simplates are the main attraction.

Testing

Aspen includes a test client to help you test your website.

Here's a basic test script using pytest:

from pytest import yield_fixture
from aspen.testing.client import Client

@yield_fixture
def client():
    yield Client(www_root='www')

def test_my_page_greetings_programs(client):
    response = client.GET('/my/page.html')
    assert response.body == "Greetings, program!"

The client provides both GET and POST methods. The first argument is an URL path (not a file path). If a given URL is expected to raise a response, you can capture it using the x variants:

def test_changing_thing_breaks(client):
    response = client.PxST('/change-thing.html', data={'foo': 'bar'})
    assert response.code == 400

Each client instance instantiates a separate website instance. It does this lazily, when you actually perform a request using GET or POST. You can call hydrate_website to trigger this directly.

Home