Skip to main content

Yet another unittest extension for python.

Project description

Yet another unittest extension for python.

Live Server Test Case

The LiveServerTestCase extension does basically the same as unittest.TestCase but also launches a live http server in a separate thread.

A comma-separated list of ports or a range of ports can be specified in the hope the live server can find one that is free to use for the WSGI server. The range may be of the form: ‘8000-8010,8080,9020-9300’ and will be read from the ‘LIVE_TEST_SERVER_ADDRESS’ environment variable.

The function create_app() is used to return the handler used by the WSGI server.

Example

import unisquid
import urllib
import wsgiref


class TestLiveServer(unisquid.LiveServerTestCase):
    def create_app(self):
        return wsgiref.simple_server.demo_app

    def test_server_process_listening(self):
        response = urllib.urlopen(self.live_server_url)
        self.assertTrue(b'Hello world!' in response.read())
        self.assertEqual(response.code, 200)

Project details


Release history Release notifications

This version

1.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for unisquid, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size unisquid-1.0.1.tar.gz (5.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page