Oktest 0.13.0 is released.
https://pypi.python.org/pypi/Oktest/
Oktest is a new-style testing library for Python.
## unittest
self.assertEqual(x, y)
self.assertNotEqual(x, y)
self.assertGreaterEqual(x, y)
self.assertIsInstance(obj, cls)
self.assertRegexpMatches(text, rexp)
## Oktest.py
ok (x) == y
ok (x) != y
ok (x) >= y
ok (obj).is_a(cls)
ok (text).match(rexp)
It is possible to assert WebOb/Werkzeug/Requests response object easily.
ok (response).is_response(200).json({"status":"OK"})
Install
$ easy_install oktest
User's Guide
http://www.kuwata-lab.com/oktest/oktest-py_users-guide.html
Changes
http://www.kuwata-lab.com/oktest/oktest-py_CHANGES.txt
What's New
----------
* [enhance] `ok().is_response()' now supports Requests.
Example::
import requests
resp = requests.get('http://www.example.com/')
ok (resp).is_response(200, 'text/html')
* [enhance] (Experimental) Add 'oktest.web' module to help WSGI app testing.
Example::
## create WSGI application
class App(object):
def __call__(self, environ, start_response):
status = '200 OK'
headers = [('Content-Type', 'application/json')]
body = [b'''{"message":"Hello!"}'''] # bytes, not unicode
start_response(status, headers)
return body
app = App()
## test for app
import unittest
import oktest
from oktest import test, ok, subject
from oktest.web import WSGITest # !!!!!
http = WSGITest(app) # !!!!!
https = WSGITest(app, {'HTTPS': 'on'}) # !!!!!
class AppTest(unittest.TestCase):
with subject('GET /'):
@test("Returns messaging JSON.")
def _(self):
resp = http.GET('/') # or http('GET', '/')
ok (resp).is_response(200).json({"message": "Hello!"})
## or
status, headers, body = http.GET('/') # or http('GET',
'/')
ok (status) == '200 OK'
ok (headers) == [('Content-Type', 'application/json')]
ok (body) == [b'''{"message":"Hello!"}''']
if __name__ == '__main__':
oktest.main()
--
regars,
makoto kuwata
--
https://mail.python.org/mailman/listinfo/python-list