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


Groups > comp.lang.python > #12262

[ANN] Oktest 0.9.0 released - a new-style testing library

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <kwatch@gmail.com>
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; 'subject:ANN': 0.02; 'example:': 0.03; 'subject:released': 0.03; 'python.': 0.04; 'skip': 0.04; 'instance': 0.05; 'library,': 0.05; 'skip:` 10': 0.07; 'unittest': 0.07; 'url:pypi': 0.08; 'assert': 0.09; 'attribute.': 0.09; 'command-line': 0.09; 'decorator': 0.09; 'dependency': 0.09; 'subject:library': 0.09; 'url:packages': 0.09; 'value)``': 0.09; 'subject:] ': 0.14; 'def': 0.15; 'library': 0.15; 'method.': 0.15; '"d",': 0.16; '"y":': 0.16; "'a'": 0.16; "'foo')": 0.16; '2")': 0.16; 'assertion': 0.16; 'boolean': 0.16; 'cool!': 0.16; 'life!': 0.16; 'name):': 0.16; 'new-style': 0.16; 'testcase': 0.16; 'arguments': 0.18; 'exists': 0.18; 'integrate': 0.18; 'interface': 0.23; '(or': 0.23; '(optional)': 0.23; 'enhancements': 0.23; 'helper': 0.23; 'skip:` 20': 0.23; 'tests.': 0.23; 'changed': 0.24; 'testing': 0.24; 'sender:addr:gmail.com': 0.25; 'skip:b 20': 0.26; 'function': 0.27; 'received:209.85.220': 0.27; 'depends': 0.28; 'loop': 0.28; 'import': 0.28; 'pass': 0.29; 'module.': 0.29; 'message-id:@mail.gmail.com': 0.29; 'skip:- 30': 0.29; 'skip:( 20': 0.29; 'module': 0.30; 'subject:[': 0.30; 'solved': 0.30; "skip:' 10": 0.30; 'class': 0.30; 'reporting': 0.31; 'changes': 0.31; 'error': 0.32; 'expression': 0.32; 'hi,': 0.32; 'error.': 0.32; 'to:addr:python-list': 0.33; 'instead': 0.33; 'message.': 0.34; 'test': 0.34; 'project': 0.34; 'skip:@ 10': 0.34; 'regular': 0.35; 'url:python': 0.36; 'using': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'url:org': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'skip:o 20': 0.38; 'subject:new': 0.38; 'ok,': 0.39; 'skip:- 10': 0.39; 'to:addr:python.org': 0.39; 'description': 0.39; 'provided': 0.60; 'free': 0.63; 'details.': 0.71; "'foo'": 0.84; 'fixture': 0.84; 'fixtures': 0.84; 'injection': 0.84; 'providers.': 0.84; 'regarded': 0.84; 'value):': 0.84; 'failures': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=U1adFGA0npo1MJO/by1kQPKinTMly9ISIzWvIHSNu5A=; b=umxGT3JhayhwEWZYrWb6jLiT1yHkhT59wH+tjEgqpRGunzew2xRZrBa51BRhgnuZVf dGv1tWuY5F2WbDA35rzSZ9zXMlW/Z6QP5nlGOK6Yf4WwildsvylA0ZGOdLxe8S+EeqZs qdgLzynvouB7iu0gFPoyLZgcoIyqzwMxR9ow4=
MIME-Version 1.0
Sender kwatch@gmail.com
Date Sat, 27 Aug 2011 21:37:45 +0900
X-Google-Sender-Auth tbfw0q7niJKQrATl9q-54nrhakQ
Subject [ANN] Oktest 0.9.0 released - a new-style testing library
From Makoto Kuwata <kwa@kuwata-lab.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.460.1314448668.27778.python-list@python.org> (permalink)
Lines 139
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314448668 news.xs4all.nl 2445 [2001:888:2000:d::a6]:53205
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12262

Show key headers only | View raw


Hi,

I released Oktest 0.9.0.
http://pypi.python.org/pypi/Oktest/
http://packages.python.org/Oktest/

Oktest is a new-style testing library for Python.
::

    from oktest import ok, NG
    ok (x) > 0                 # same as assert_(x > 0)
    ok (s) == 'foo'            # same as assertEqual(s, 'foo')
    ok (s) != 'foo'            # same as assertNotEqual(s, 'foo')
    ok (f).raises(ValueError)  # same as assertRaises(ValueError, f)
    ok (u'foo').is_a(unicode)  # same as assert_(isinstance(u'foo', unicode))
    NG (u'foo').is_a(int)      # same as assert_(not isinstance(u'foo', int))
    ok ('A.txt').is_file()     # same as assert_(os.path.isfile('A.txt'))
    NG ('A.txt').is_dir()      # same as assert_(not os.path.isdir('A.txt'))

See http://packages.python.org/Oktest/ for details.

NOTICE!! Oktest is a young project and specification may change in the future.


Main Enhancements
-----------------

* New '@test' decorator provided. It is simple but very powerful.
  Using @test decorator, you can write test description in free text
  instead of test method.
  ex::

    class FooTest(unittest.TestCase):

        def test_1_plus_1_should_be_2(self):  # not cool...
            self.assertEqual(2, 1+1)

        @test("1 + 1 should be 2")    # cool! easy to read & write!
        def _(self):
            self.assertEqual(2, 1+1)

* Fixture injection support by '@test' decorator.
  Arguments of test method are regarded as fixture names and
  they are injected by @test decorator automatically.
  Instance methods or global functions which name is 'provide_xxxx' are
  regarded as fixture provider (or builder) for fixture 'xxxx'.
  ex::

    class SosTest(unittest.TestCase):

        ##
        ## fixture providers.
        ##
        def provide_member1(self):
            return {"name": "Haruhi"}

        def provide_member2(self):
            return {"name": "Kyon"}

        ##
        ## fixture releaser (optional)
        ##
        def release_member1(self, value):
            assert value == {"name": "Haruhi"}

        ##
        ## testcase which requires 'member1' and 'member2' fixtures.
        ##
        @test("validate member's names")
        def _(self, member1, member2):
            assert member1["name"] == "Haruhi"
            assert member2["name"] == "Kyon"

  Dependencies between fixtures are resolved automatically.
  ex::

    class BarTest(unittest.TestCase):

        ##
        ## for example:
        ## - Fixture 'a' depends on 'b' and 'c'.
        ## - Fixture 'c' depends on 'd'.
        ##
        def provide_a(b, c):  return b + c + ["A"]
        def provide_b():      return ["B"]
        def provide_c(d):     return d + ["C"]
        def provide_d():      reutrn ["D"]

        ##
        ## Dependencies between fixtures are solved automatically.
        ##
        @test("dependency test")
        def _(self, a):
            assert a == ["B", "D", "C", "A"]

  If loop exists in dependency then @test reports error.

  If you want to integrate with other fixture library, see the following
  example::

      class MyFixtureManager(object):
          def __init__(self):
              self.values = { "x": 100, "y": 200 }
          def provide(self, name):
              return self.values[name]
          def release(self, name, value):
              pass

      oktest.fixure_manager = MyFixtureResolver()



Other Enhancements and Changes
------------------------------

* Supports command-line interface to execute test scripts.
* Reporting style is changed.
* New assertion method ``ok(x).attr(name, value)`` to check attribute.
* New assertion method ``ok(x).length(n)``.
* New feature``ok().should`` helps you to check boolean method.
* 'ok(str1) == str2' displays diff if text1 != text2, even when using
  with unittest module.
* Assertion ``raises()`` supports regular expression to check error message.
* Helper functions in oktest.dummy module are now available as decorator.
* 'AssertionObject.expected' is renamed to 'AssertionObject.boolean'.
* ``oktest.run()`` is changed to return number of failures and errors of tests.
* ``before_each()`` and ``after_each()`` are now non-supported.
* (Experimental) New function ``NOT()`` provided which is same as ``NG()``.
* (Experimental) ``skip()`` and ``@skip.when()`` are provided to skip tests::

See CHANGES.txt for details.
http://packages.python.org/Oktest/CHANGES.txt


Have a nice testing life!

--
regards,
makoto kuwata

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

[ANN] Oktest 0.9.0 released - a new-style testing library Makoto Kuwata <kwa@kuwata-lab.com> - 2011-08-27 21:37 +0900

csiph-web