Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'url:pypi': 0.03; 'skip:[ 20': 0.04; 'subject:ANN': 0.07; 'test,': 0.07; '__name__': 0.09; 'bytes,': 0.09; 'http': 0.09; 'resp': 0.09; 'unittest': 0.09; 'def': 0.12; 'changes': 0.15; "'200": 0.16; "'__main__':": 0.16; 'easy_install': 0.16; 'headers,': 0.16; 'https': 0.16; 'new-style': 0.16; 'skip:[ 40': 0.16; 'subject:library': 0.16; 'url:example': 0.16; 'wsgi': 0.16; 'sender:addr:gmail.com': 0.17; 'library': 0.18; 'app': 0.19; 'module': 0.19; 'subject:] ': 0.20; '8bit%:5': 0.22; 'import': 0.22; 'install': 0.23; 'headers': 0.24; 'skip:` 20': 0.24; 'unicode': 0.24; '----------': 0.26; 'testing': 0.29; 'skip:( 40': 0.30; 'skip:@ 10': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'requests': 0.31; 'assert': 0.31; 'skip:( 50': 0.31; 'testing.': 0.31; "user's": 0.31; 'class': 0.32; 'url:python': 0.33; 'skip:_ 10': 0.34; 'skip:s 30': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'possible': 0.36; 'url:org': 0.36; 'application': 0.37; 'subject:new': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'skip:& 20': 0.39; 'subject:[': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'new': 0.61; 'skip:n 10': 0.64; 'messaging': 0.68; 'subject': 0.69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=AJU/++wL4L7d478Ng3SzK93xN61ZKYd/DudkH1NkVgM=; b=IJbnA1JhCq0YIqFNeult1tUhXnP4N8Kog9EtPecmyp4/x/LOabrnlUUJt49B8ardpc 4qGb8dIbhoupzZGVNiR0s9zaQkvyqh4UubAiEy0NtQmU5epOg0ZhqM9J+tGyydAlDEld NguO8U5W71UlqYaRA53i7TBV1cJCUWEdiWUtg0QA8PzzfWaUfRtm0HS7bC1wosSws6Ed tPh6K4814HFVo6y1S7Oq1TsB0ceK2B4CR/Cdlk20ATvR6El4GFJy5e+NoAKHufenTBFR 7r8lNT6uK07MIN88qK6WDxAIHxq8sHV3By+/LfzEkajjShJA9MTjAJUMt6ceaxaXvP6s GvAQ== MIME-Version: 1.0 X-Received: by 10.229.194.1 with SMTP id dw1mr7473252qcb.20.1390439692732; Wed, 22 Jan 2014 17:14:52 -0800 (PST) Sender: kwatch@gmail.com Date: Thu, 23 Jan 2014 10:14:52 +0900 X-Google-Sender-Auth: nKJoGg5by5gTriUM0FiDrsun_fk Subject: [ANN] Oktest.py 0.13.0 - a new style testing library From: Makoto Kuwata To: python-list@python.org Content-Type: multipart/alternative; boundary=001a11c2c736f795d104f098f7de X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 165 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390439699 news.xs4all.nl 2864 [2001:888:2000:d::a6]:52718 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64546 --001a11c2c736f795d104f098f7de Content-Type: text/plain; charset=ISO-8859-1 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 --001a11c2c736f795d104f098f7de Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Oktest 0.13.0 is released.
https://pypi.python.org/pypi/Oktest/

Oktest is a new-style testing library for Python.

=A0 =A0 ## unittest
=A0 =A0 self.assertEqual(= x, y)
=A0 =A0 self.assertNotEqual(x, y)
=A0 =A0 self.as= sertGreaterEqual(x, y)
=A0 =A0 self.assertIsInstance(obj, cls)
=A0 =A0 self.assertRegexpMatches(text, rexp)

=A0 =A0 ## Oktest.py
=A0 =A0 ok (x) =3D=3D y<= /div>
=A0 =A0 ok (x) !=3D y
=A0 =A0 ok (x) >=3D y
=A0 =A0 ok (obj).is_a(cls)
=A0 =A0 ok (text).match(rexp)
<= div>
It is possible to assert WebOb/Werkzeug/Requests respons= e object easily.

=A0 =A0 ok (response).is_response(200).json({"stat= us":"OK"})


Install
=A0 $ easy_install oktest

User's Guid= e
=

Changes


What's New
----------

* [enhance] `ok().is_response()' now supports Requ= ests.
=A0 Example::

=A0 =A0 =A0 import r= equests
=A0 =A0 =A0 resp =3D requests.get('http://www.example.com/')
=A0 =A0 =A0 ok (resp).is_r= esponse(200, 'text/html')

* [enhance] (Exp= erimental) Add 'oktest.web' module to help WSGI app testing.
=A0 Example::

=A0 =A0 =A0 ## create WSGI appl= ication
=A0 =A0 =A0 class App(object):
=A0 =A0 =A0 =A0 = =A0 def __call__(self, environ, start_response):
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 status =A0=3D '200 OK'
=A0 =A0 =A0 =A0 =A0 =A0 =A0 headers =3D [('Content-Type', '= ;application/json')]
=A0 =A0 =A0 =A0 =A0 =A0 =A0 body =A0 =A0= =3D [b'''{"message":"Hello!"}'''= ;] =A0# bytes, not unicode
=A0 =A0 =A0 =A0 =A0 =A0 =A0 start_response(status, headers)
=A0 = =A0 =A0 =A0 =A0 =A0 =A0 return body

=A0 =A0 =A0 ap= p =3D App()

=A0 =A0 =A0 ## test for app
= =A0 =A0 =A0 import unittest
=A0 =A0 =A0 import oktest
=A0 =A0 =A0 from oktest import test, ok, subject
=A0 =A0 =A0= from oktest.web import WSGITest =A0 =A0 =A0 =A0 =A0 # !!!!!

=
=A0 =A0 =A0 http =A0=3D WSGITest(app) =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 # !!!!!
=A0 =A0 =A0 https =3D WSGITest(app, {'= ;HTTPS': 'on'}) =A0 =A0# !!!!!

=A0 =A0 =A0 class AppTest(unittest.TestCase):

=A0 =A0 =A0 =A0 =A0 with subject('GET /'):

=A0 =A0 =A0 =A0 =A0 =A0 =A0 @test("Returns messaging = JSON.")
=A0 =A0 =A0 =A0 =A0 =A0 =A0 def _(self):
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 resp =3D http.GET('/') =A0= =A0 # or http('GET', '/')
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 ok (resp).is_response(200).json({"message": "= ;Hello!"})
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ## or
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 status, headers, body =3D http.GET= ('/') =A0 # or http('GET', '/')
=A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 ok (status) =A0=3D=3D '200 OK'
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ok (headers) =3D=3D [('Content-Ty= pe', 'application/json')]
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ok (body) =A0 =A0=3D=3D [b'= 9;'{"message":"Hello!"}''']
<= br>
=A0 =A0 =A0 if __name__ =3D=3D '__main__':
= =A0 =A0 =A0 =A0 =A0 oktest.main()


--
regars,
makoto kuwata<= /div>

--001a11c2c736f795d104f098f7de--