Ticket #1284 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

TestCase: support of doctest

Reported by: bdelbosc Assigned to: bdelbosc
Priority: P1 Milestone: unspecified
Component: funkload Version: unspecified
Severity: normal Keywords: doctest
Cc:

Description

TestCase?: support of doctest

  • make it easy to write doctest using funkload
  • make fl-run-test load and run doctest like unittest

Change History

01/26/06 15:08:05 changed by bdelbosc

  • status changed from new to closed.
  • resolution set to fixed.

cf CHANGES.txt in the trunk::

  There is a new FunkLoadDocTest class that ease usage of FunkLoad from
  doctest so you can simply do::

    >>> from funkload.FunkLoadDocTest import FunkLoadDocTest
    >>> fl = FunkLoadDocTest()
    >>> response = fl.get('http://localhost/')
    >>> 'HTML' in response.body
    True
    >>> response
    <response url="http://127.0.0.1:80//" code="200" message="OK" />


  The test runner ``fl-run-test`` is now able launch doctest from a plain text
  file or embedded in python docstring::

     $ fl-run-test -v doctest_dummy.txt
     Doctest: doctest_dummy.txt          Ok
     -----------------------------------------------------
     Ran 1 test in 0.077s
     OK

  And the ``--debug`` option makes doctests verbose::

     $ fl-run-test -d doctest_dummy.txt
     ...
     Trying:
         fl = FunkLoadDocTest()
     Expecting nothing
     ok
     Trying:
         fl.get('http://localhost/')
     Expecting:
         <response url="http://127.0.0.1:80//" code="200" message="OK" />
     ok
     Ok
     ----------------------------------------------------------------------
     Ran 1 test in 0.051s
     OK