[TIP] Getting started writing DocTests for Web applications

Olemis Lang olemis at gmail.com
Fri Jan 16 06:35:50 PST 2009


On Fri, Jan 16, 2009 at 2:49 AM, Fran Boon <flavour at partyvibe.com> wrote:
> I have started a project to rewrite Sahana in Python.
>
> We have ambitious plans to do quality testing:
> https://trac.sahanapy.org/wiki/DeveloperGuidelinesTesting
>
> I'd like to start with doc tests as these make for inline docs for
> developers & can build automatic API docs using epydoc.
>
> I'm having trouble getting started as examples look at nice clear
> mathematical operations whilst our functions mostly generate HTML.
> Once there are a couple of examples to copy, this will make it easier to
> incorporate throughout.
>

Use doctest or dutest [1]_ loaders and specify an HTML-aware output
checker (e.g. lxml.doctestcompare.LHTMLOutputChecker [3]_, [4]_ ...)

Perhaps there are different options out there ... Pls feel free to
send us (the list ;) feedback about your research ...

> For unit tests, there seem to be several good options such as WebUnit or
> CheeryPy's WebTest.
>

;) ... If using unittest-like TCs ... You could easily put together
your test suites using dutest.MultiTestLoader to load them at once ...
and there is also another loader available to load the tests found in
a specified folder and subfolders ... using regex filters too ... ;)

An article [2]_ covers something like this by using dutest module ...
perhaps some minor modifications are required since new versions may
have introduced either enhancements or bug fixes ...


.. [1] Package Index > dutest 0.2.2
        (http://pypi.python.org/pypi/dutest)

.. [2] "Doctest and unittest... now they'll live happily together", O.
Lang (2008) The Python Papers, Volume 3, Issue 1, pp. 31:51
          (http://ojs.pythonpapers.org/index.php/tpp/article/viewArticle/56)

.. [3] lxml.doctestcompare
        (http://codespeak.net/svn/lxml/trunk/src/lxml/doctestcompare.py)

.. [4] lxml.doctestcompare
        (http://codespeak.net/lxml/api/lxml.doctestcompare-pysrc.html)

-- 
Regards,

Olemis.

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

Featured article:
Añadir gadgets de Google en entradas (artículos) de Blogger.



More information about the testing-in-python mailing list