Oktest 0.7.0 released - a new-style testing library

Discussion in 'Python' started by Makoto Kuwata, Feb 5, 2011.

  1. I released Oktest 0.7.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
    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 http://packages.python.org/Oktest/ 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
    #
    @oktest.assertion
    def startswith(self, arg):
    boolean = self.target.startswith(arg)
    if boolean == self.expected:
    return True
    self.failed("%r.startswith(%r) : failed." % (self.target, 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 sys.stdin.read() == "SOS"
    print("Haruhi")
    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.

    --
    regards,
    makoto kuwata
     
    Makoto Kuwata, Feb 5, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kwatch
    Replies:
    0
    Views:
    271
    kwatch
    Apr 19, 2010
  2. kwatch
    Replies:
    0
    Views:
    207
    kwatch
    May 16, 2010
  3. Makoto Kuwata
    Replies:
    0
    Views:
    268
    Makoto Kuwata
    Jun 27, 2010
  4. Makoto Kuwata
    Replies:
    0
    Views:
    192
    Makoto Kuwata
    Jan 23, 2011
  5. Makoto Kuwata
    Replies:
    0
    Views:
    182
    Makoto Kuwata
    Feb 15, 2011
Loading...

Share This Page