FAQ
Hi,
I released Oktest 0.2.2.

http://packages.python.org/Oktest/
http://pypi.python.org/pypi/Oktest/


Overview
--------

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

from oktest import ok
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))
not_ok (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'))
not_ok ('A.txt').is_dir() # same as assert_(not os.path.isdir('A.txt'))

You can use ok() instead of 'assertXxx()' in unittest.

Oktest requires Python 2.3 or later. Oktest is ready for Python 3.

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

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


Changes
-------

* Enhanced to set 'f.exception' after 'ok (f).raises(Exception)'
to get raised exception object. For example::

def f():
int('foobar')
ok (f).raises(ValueError)
ok (f.exception.message) == "invalid literal for int() with base
10: 'foobar'"

* Changed to flush output after '.'/'f'/'E' printed

* Change to get exception message by 'str(ex)' instead of 'ex.message'


Have fun!

--
regards,
makoto kuwata

Search Discussions

  • Jonathan Fine at Apr 25, 2010 at 3:51 pm

    Makoto Kuwata wrote:
    Hi,
    I released Oktest 0.2.2.

    http://packages.python.org/Oktest/
    http://pypi.python.org/pypi/Oktest/


    Overview
    --------

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

    from oktest import ok
    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))
    not_ok (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'))
    not_ok ('A.txt').is_dir() # same as assert_(not os.path.isdir('A.txt'))

    You can use ok() instead of 'assertXxx()' in unittest.

    Oktest requires Python 2.3 or later. Oktest is ready for Python 3.

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

    See http://packages.python.org/Oktest/ for details.
    This reminds me a bit of my own in-progress work
    http://bitbucket.org/jfine/python-testutil/

    Here's an example of how it works:
    def plus(a, b): return a + b
    def minus(a, b): return a - b
    def square(a): return a * a
    x = TestScript(
    ... plus,
    ... (
    ... f(2, 2) == 5,
    ... )
    ... )
    x.run()
    [WrongValue(5, 4)]
    y = TestScript(
    ... dict(f=plus, g=square, h=map),
    ... (
    ... f(2, 2) == 5,
    ... h(g, (1, 2, 3)) == [1, 3, 6],
    ... )
    ... )
    y.run()
    [WrongValue(5, 4), WrongValue([1, 3, 6], [1, 4, 9])]


    But it's not yet ready for use.
    --
    Jonathan

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 25, '10 at 12:21p
activeApr 25, '10 at 3:51p
posts2
users2
websitepython.org

2 users in discussion

Jonathan Fine: 1 post Makoto Kuwata: 1 post

People

Translate

site design / logo © 2022 Grokbase