sample_doctest.py 1.01 KB
Newer Older
1
"""This is a sample module that doesn't really test anything all that
2
   interesting.
3

4
It simply has a few tests, some of which succeed and some of which fail.
5

6
It's important that the numbers remain constant as another test is
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
testing the running of these tests.


>>> 2+2
4
"""


def foo():
    """

    >>> 2+2
    5

    >>> 2+2
    4
    """

def bar():
    """

    >>> 2+2
    4
    """

def test_silly_setup():
    """

    >>> import test.test_doctest
    >>> test.test_doctest.sillySetup
    True
    """

def w_blank():
    """
    >>> if 1:
    ...    print 'a'
    ...    print
    ...    print 'b'
    a
    <BLANKLINE>
    b
    """

x = 1
def x_is_one():
    """
    >>> x
    1
    """

def y_is_one():
    """
    >>> y
    1
    """

64 65 66 67 68 69 70 71 72 73
__test__ = {'good': """
                    >>> 42
                    42
                    """,
            'bad':  """
                    >>> 42
                    666
                    """,
           }

74 75 76
def test_suite():
    import doctest
    return doctest.DocTestSuite()