Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Oktest 0.7.0 released - a new-style testing library

Thread Tools

Oktest 0.7.0 released - a new-style testing library

Makoto Kuwata
Posts: n/a
I released Oktest 0.7.0.

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'))

See for details.

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

Enhancements and Changes

* enhanced to allow users to define custom assertion functions. ::

import oktest
from oktest import ok
def startswith(self, arg):
boolean =
if boolean == self.expected:
return True
self.failed("%r.startswith(%r) : failed." % (, arg))
ok ("Sasaki").startswith("Sas")

* rename 'ok().hasattr()' to 'ok().has_attr()'.
(but old name is also available for backward compatibility.)

* change 'chdir()' to take a function as 2nd argument. ::

def f():
... do_something ...
chdir('build', f)

# The above is same as:
with chdir('build'):
... do_something ...

* add document of 'oktest.helper.dummy_io()'. ::

with dummy_io("SOS") as io:
assert == "SOS"
assert io.stdout == "Haruhi\n"
assert io.stderr == ""

* fix 'oktest.tracer.Call#__repr__()' to change output according to
whether '==' is called or not. This is aimed to make output of
'ok(tr[0]) == [...]' to be more readable.

* change 'Runner#run()' to skip AssertionError if it is raised by
'assert ....' and not 'ok() == ...'.

* fix example code for some helper functions.

makoto kuwata
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] Oktest 0.8.0 released - a new-style testing library Makoto Kuwata Python 0 02-15-2011 03:44 PM
[ANN] Oktest 0.6.0 released - a new-style testing library Makoto Kuwata Python 0 01-23-2011 02:00 AM
[ANN] Oktest 0.4.0 released - a new-style testing library Makoto Kuwata Python 0 06-26-2010 11:28 PM
[ANN] Oktest 0.3.0 released - a new style testing library kwatch Python 0 05-16-2010 07:46 AM
ANN: Oktest 0.2.1 released - a new style testing library. kwatch Python 0 04-19-2010 10:25 PM