Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63765 > unrolled thread

[ANN] Oktest.py 0.12.0 released - a new-style testing library

Started byMakoto Kuwata <kwa@kuwata-lab.com>
First post2014-01-12 21:38 +0900
Last post2014-01-12 08:02 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  [ANN] Oktest.py 0.12.0 released - a new-style testing library Makoto Kuwata <kwa@kuwata-lab.com> - 2014-01-12 21:38 +0900
    Re: [ANN] Oktest.py 0.12.0 released - a new-style testing library Roy Smith <roy@panix.com> - 2014-01-12 08:02 -0500

#63765 — [ANN] Oktest.py 0.12.0 released - a new-style testing library

FromMakoto Kuwata <kwa@kuwata-lab.com>
Date2014-01-12 21:38 +0900
Subject[ANN] Oktest.py 0.12.0 released - a new-style testing library
Message-ID<mailman.5364.1389530289.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hi,

I released Oktest 0.12.0.
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)


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


Highlight on this release
-------------------------

This release contains new and important enhancements.

* [enhance] `ok (actual) == expected' reports unified diff.
  Example::

    AssertionError:
    --- expected
    +++ actual
    @@ -1,3 +1,3 @@
     {'email': 'haruhi@sos-brigade.org',
    - 'gender': 'Female',
    + 'gender': 'female',
      'username': 'Haruhi'}

* [enhance] @at_end decorator registers callback which is called
  at end of test case. ::

      @test("example to remove temporary file automatically")
      def _(self):
        ## create dummy file
        with open('dummy.txt', 'w') as f:
          f.write("blablabla")
        ## register callback to delete dummy file at end of test case
        @at_end
        def _():
          os.unlink(tmpfile)
        ## do test
        with open(tmpfile) as f:
          ok (f.read()) == "blablabla"

* [enhance] New assertions for WebOb/Werkzeug response object. ::

     ok (resp).is_response(200)                          # status code
     ok (resp).is_response((302, 303))                   # status code
     ok (resp).is_response('200 OK')                     # status line
     ok (resp).is_response(200, 'image/jpeg')            # content-type
     ok (resp).is_response(200, re.compile(r'^image/(jpeg|png|gif)$'))
     ok (resp).is_response(302).header("Location", "/")  # header
     ok (resp).is_response(200).json({"status": "OK"})   # json data
     ok (resp).is_response(200).body("<h1>Hello</h1>")   # response body
     ok (resp).is_response(200).body(re.compile("<h1>.*?</h1>"))

* [bugfix] @todo decorator now supports fixture injection. ::

     @test('example')
     @todo             # error on previous version but not on this release
     def _(self, x):
         assert False


You can see all enhancements and changes. See
  http://www.kuwata-lab.com/oktest/oktest-py_CHANGES.txt


Have fun!

--
regards,
makoto kuwata

[toc] | [next] | [standalone]


#63768

FromRoy Smith <roy@panix.com>
Date2014-01-12 08:02 -0500
Message-ID<roy-D9BDA2.08021112012014@news.panix.com>
In reply to#63765
In article <mailman.5364.1389530289.18130.python-list@python.org>,
 Makoto Kuwata <kwa@kuwata-lab.com> wrote:

> Hi,
> 
> I released Oktest 0.12.0.
> https://pypi.python.org/pypi/Oktest/

Wow, this looks neat.  We use nose, but I'm thinking your ok() style 
exceptions should work just fine with nose.  Just the notational 
convenience alone is worth it.  Typing "ok(x) <= 1" is so much nicer 
than "assert_less(x, 1)".

Unfortunately, I was unable to download it.  There seems to be a broken 
redirect at pypi:

$ wget 
http://pypi.python.org/packages/source/O/Oktest/Oktest-0.12.0.tar.gz
--2014-01-12 07:57:01--  
http://pypi.python.org/packages/source/O/Oktest/Oktest-0.12.0.tar.gz
Resolving pypi.python.org (pypi.python.org)... 199.27.72.184, 
199.27.72.185
Connecting to pypi.python.org (pypi.python.org)|199.27.72.184|:80... 
connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: 
https://pypi.python.org/packages/source/O/Oktest/Oktest-0.12.0.tar.gz 
[following]
--2014-01-12 07:57:01--  
https://pypi.python.org/packages/source/O/Oktest/Oktest-0.12.0.tar.gz
Connecting to pypi.python.org (pypi.python.org)|199.27.72.184|:443... 
connected.
HTTP request sent, awaiting response... 404 Not Found
2014-01-12 07:57:02 ERROR 404: Not Found.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web