[Zope3-dev] Re: [Zope-Checkins] CVS: Zope3/src/persistent/tests-test_persistent.py:1.5 persistent.txt:1.2

Tim Peters tim at zope.com
Fri Mar 12 10:36:46 EST 2004


[Chris Withers]
> Hmmm... okay, how do I do a rectangle copy in emacs?

Sorry, I last used emacs 10 years ago, and long-term retention of its
gibberish keystroke sequences isn't among its virtues <wink>.  Go to

    http://www.google.com/

Then type

    emacs rectangle

in the text box, and hit the

    I'm Feeling Lucky

button.

>  >>> doctest.testsource('test.test_generators','tutorial_tests')
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>    File "C:\Python23\lib\doctest.py", line 1392, in testsource
>      raise ValueError(name, "not found in tests")
> ValueError: ('tutorial_tests', 'not found in tests')
>
> What am I doing wrong here?

testsource() doesn't know about __test__ dicts, and I don't think Jim did
either.  So none of the Zope doctests use __test__, and none of the doctest
extensions Jim wrote know about __test__ either.  Stick this in junk.py:

class A:
    """
    Creating an A yields an object of type A:

    >>> a = A()
    >>> print type(a) is A
    True
    """

Then

>>> import doctest
>>> import junk
>>> print doctest.testsource(junk, 'A')
a = A()
print type(a) is A
# Expect:
# True
#
>>>

The "name" testsource expects is really an object path (possibly dotted;.

...
> Hmmm... I guess I'm more concerned with the fact my editor won't
> understand doctest, whereas it does understand python...

Why is that a concern?  For example, did you struggle with understanding the
meaning of class A's docstring above (I assume your mail reader doesn't
understand doctest or Python)?  Did you struggle with the Python tutorial
(which is darned close to *being* a doctest, except because it isn't really
some of the tutorial examples are always out of synch with what current
Python actually does).  Good doctests typically have blocks of English
exposition interspersed with small snippets of Python, and read like a
tutorial, or like a paper containing Python examples.




More information about the Zope3-dev mailing list