Issue #255 new

(doc)tests issues

Thomas Waldmann
created an issue

it's not documented how to run the unit tests, so if one sees a failing / erroneous test, there's some uncertainty whether one has run them in the right way.

running "nosetests" from the top directory seems to work.

but running "nosetests --with-doctest" gives lots of errors and failures (for python 2.7).

while trying to fix some of them, I noticed that there might be an issue with python2 vs. python3 and that tuning the doctests to work for python2 AND 3 might be a rather tedious job.

are the doctests only expected to work for python3?

shall they get migrated to separate tests?

Comments (3)

  1. Matt Chaput repo owner

    There are no doctests. Or rather, I've never run doctests, don't know much about doctests, and don't write the examples to be doctests. It would be nice to automatically check that examples stay relevant, but many of the examples of doctests I've seen embedded lots of doctest-related junk that's ugly and distracting. I guess I should learn more about it.

    It would make sense to make a readme explaining that Whoosh uses nose and that you can do "nosetests" or "python setup.py test" to run the unit tests.

  2. Thomas Waldmann reporter
    """
    >>> print "that is a doctest"
    'that is a doctest'
    """
    

    :-)

    well, maybe we need to remove those >>> if they are intended to just be examples. but if you want to check them, I guess they better are doctests, so you can run them.

    that said, there are some python2/python3 related issues that might make that a pain, because doctest just compares whatever is output by the code to whatever you have told you expect - character by character.

  3. Thomas Waldmann reporter

    Some documentation about the issues of doctests and python2 / python3:

    http://python3porting.com/problems.html http://python3porting.com/problems.html

    It looks like a complicated pain to support both pythons.

    So, Matt, what do you think? Looks like the options are:

    a) Abandon doctests (and risk that untested "examples" don't work)? Maybe change the examples in a way, so that they don't look like doctests (so noone/nothing misinterprets them as doctests)?

    b) Support doctests only for py2? (for now)

    c) Support doctests only for py3?

    d) Try to support doctests both with py2 AND py3 at the same time?

    I personally would tend to b), c), a), d) - in that order. Can't help with c) and d), though.

  4. Log in to comment