[Python-Dev] unittest package

Olemis Lang olemis at gmail.com
Fri Apr 3 14:41:52 CEST 2009

On Thu, Apr 2, 2009 at 6:07 PM, Barry Warsaw <barry at python.org> wrote:
> On Apr 2, 2009, at 4:58 PM, Michael Foord wrote:
>> The unittest module is around 1500 lines of code now, and the tests are
>> 3000 lines.
>> It would be much easier to maintain as a package rather than a module.
>> Shall I work on a suggested structure or are there objections in principle?
> +1/jfdi :)

I remember that something like this was discussed some time ago ...
perhaps the ideas mentionned that time might be valuable ... AFAICR
somebody provided an example ... ;)

+1 for unittest as a package ...

BTW ... Q: Does it means that there will be subpkgs for specific (...
yet standard ...) pkgs ?

If this is the case, and there is a space for a unittest.doctest pkg
(... or whatever ... the name may be different ;) ... and inclusion is
Ok ... and so on ... I wonder ...

Q: Is it possible that dutest module [1]_ be considered ... to live in
stdlib ... ?

The module integrates doctest + unittest ... without needing a plugin
architecture or anything like that, just unittest + doctest... (... in
fact, sometimes I dont really get the idea for having plugins in
testing framews for what can be done following unittest philosophy ...
but anyway ... this is a long OT thread ... and I dont even think to
continue ... was just a brief comment ...)

- DocTestLoader allows to load (using unittest-style) TestCases which
check the match made for doctests. It provides integration with
TestProgram, supports building complex TestSuites in a more natural
way, and eases the use of specialized instances of TestCases built out
of doctest examples.

- A few classes so as to allow reporting the individual results of
each and every interactive example executed during the test run. A
separate entry is created in the corresponding TestResult instance
containing the expected value and the actual result.

- PackageTestLoader class (acting as a decorator ... design pattern ;)
loads all the tests found throughout a package hierarchy using another
loader . The later is used to retrieve the tests found in modules
matching a specified pattern.

- dutest.main is an alias for dutest.VerboseTestProgram. This class
fixes a minor bug (... IMO) I found while specifying different
verbosity levels from the command line to unittest.TestProgram.

These are the classes right now, but some others (e.g.
DocTestScriptLoader ... to load doctests out of test scripts ...)
might be helpful as well ... ;o)

Download from PyPI
dutest-0.2.2.win32.exe  MS Windows installer  any 76KB          28
dutest-0.2.2-py2.5.egg  Python Egg  2.5  17KB                           93
dutest-0.2.2.zip              Source    any   13KB

PS: Random thoughts ...

.. [1] dutest 0.2.2

.. [2] "Doctest and unittest... now they'll live happily together", O.
Lang (2008) The Python Papers, Volume 3, Issue 1, pp. 31:51



Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
No me gustan los templates de Django ...

More information about the Python-Dev mailing list