TestCase that will launch your wsgi/werkzeug application in a separate thread for you
Project description
- Version:
- 0.1
TestCase that will launch your wsgi/werkzeug application in a separate thread for you (using setUp and tearDown methods).
Inspired by Django’s LiveServerTestCase.
How to
import requests # you should use this, requests is cool
from wsgitestcase import WsgiTestCase
class MyTestCase(WsgiTestCase):
# add your wsgi application here
# you can also set it with something like
# app = staticmethod(my_wsgi_app)
# see tests.py for more examples
@staticmethod
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield 'Hello World'
def test_something(self):
# server with your app should be already up
# use self.host, self.port and self.url to find out where it is
r = requests.get("http://%s:%s/" % (self.host, self.port))
self.assertEqual(r.text, "Hello World")
# in self.requests you can find a list with all requests made to
# your app. it contains werkzeug's Request objects.
# see tests.py for more examples
# and werkzeug's doc at http://werkzeug.pocoo.org/docs/wrappers/
# for Request object reference
self.assertEqual(len(self.requests), 1)
self.assertEqual(self.requests[0].path, "/")
License
wsgitestcase is distributed under terms of MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wsgitestcase-0.1.tar.gz
(4.8 kB
view details)
File details
Details for the file wsgitestcase-0.1.tar.gz
.
File metadata
- Download URL: wsgitestcase-0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 813f8c6d2007981014bcbd839c1de5745265cf43383dcc5144d32200d1817b6c |
|
MD5 | baa3417c0591d6bfd572ee550518c15e |
|
BLAKE2b-256 | 727892a8934fc6c007eb123f189db186b7922595dcb7e0096055a459e78e532f |