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

Makoto Kuwata kwa at kuwata-lab.com
Sat Nov 19 23:30:22 EST 2011


I released Oktest.py 0.11.0.
http://pypi.python.org/pypi/Oktest/
http://packages.python.org/Oktest/

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

    from oktest import ok, NG
    ok (x) > 0                 # same as assertTrue(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 assertTrue(isinstance(u'foo', unicode))
    NG (u'foo').is_a(int)      # same as assertTrue(not isinstance(u'foo', int))
    ok ('A.txt').is_file()     # same as assertTrue(os.path.isfile('A.txt'))
    NG ('A.txt').is_dir()      # same as assertTrue(not os.path.isdir('A.txt'))

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


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

* [change] 'spec()' is now NOT obsoleted.

* [change] 'spec()' is now available as function decorator.
  ex::

    class FooTest(unittest.TestCase):
      def test_method1(self)
        @spec("1+1 should be 2")
	def _():
	  ok (1+1) == 2
        @spec("1-1 should be 0")
	def _():
	  ok (1-1) == 0

* [enhance] New assertions: not_file(), not_dir() and not_exist().
  ex::

    ok (".").not_file()         # same as NG (".").is_file()
    ok (__file__).not_dir()     # same as NG (__file__).is_dir()
    ok ("foobar").not_exist()   # same as NG ("foobar").exists()

* [enhance] New assertion: not_match().
  ex::

    ok ("SOS").not_match(r"\d+")  # same as NG ("SOS").matches(r"\d+")

* [enhance] Global provider/releaser functions can take 'self' argument.
  ex::

    def provide_logname(self):
        self._LOGNAME = os.getenv('LOGNAME')
	os.environ['LOGNAME'] = "Haruhi"
	return os.environ['LOGNAME']

    def release_logname(self, value):
        os.environ['LOGNAME'] = self._LOGNAME

* [change] Change not to ignore test classes which name starts with '_'.

* [change] (internal) Move some utility functions to 'util' module.

* [change] (internal) Move '_Context' and '_RunnableContext' classes
into 'util' module.

* [change] (internal) Move 'Color' class into 'util' module

* [change] (internal) Remove 'OUT' variable in 'Reporter' class

* [change] (internal) Move 'TARGET_PATTERN' variable to 'config'

* [bugfix] Fix to clear ImportError after trying to import unittest2


--
regards,
makoto



More information about the Python-list mailing list