doctest with variable return value

3KWA eugene at boardkulture.com
Tue Jul 25 03:53:40 EDT 2006


Hi all,

I am wondering what is the standard doctest (test) practice for
functions who's returned value change all the time e.g. forex rate:

import urllib

def get_rate(symbol):
    """get_rate(symbol) connects to yahoo finance to return the rate of
symbol.

    >>>get_rate('AUDEUR')

    """

    url=
"http://finance.yahoo.com/d/quotes.csv?s=%s=X&f=sl1d1t1c1ohgv&e=.csv" %
\
         symbol
    f=urllib.urlopen(url)
    return float(f.readline().split(',')[1])

As you can guess I am very new to unittest and doctest in general ...

Thanks for your help,

EuGeNe




More information about the Python-list mailing list