1 2 3 4 5 6 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#!/usr/bin/env python
"""
This file contains doctests with errors. Executing xdoctest on this file will
demo how xdoctest reports errors. (It can also be used / was created for
debugging)
"""
def demo1():
"""
CommandLine:
xdoctest -m ~/code/xdoctest/dev/demo/demo_errors.py demo1
Example:
>>> raise Exception('demo1')
"""
pass
def demo2():
"""
CommandLine:
xdoctest -m ~/code/xdoctest/dev/demo/demo_errors.py demo2
Example:
>>> print('error on different line')
>>> raise Exception('demo2')
"""
pass
def demo3():
"""
CommandLine:
xdoctest -m ~/code/xdoctest/dev/demo/demo_errors.py demo3
Example:
>>> print('demo5')
demo3
"""
pass
class Demo5:
"""
CommandLine:
xdoctest -m ~/code/xdoctest/dev/demo/demo_errors.py Demo5
Example:
>>> raise Exception
"""
def demo5(self):
"""
CommandLine:
xdoctest -m ~/code/xdoctest/dev/demo/demo_errors.py Demo5.demo5
Example:
>>> raise Exception
"""
pass
def demo_parsetime_syntax_error1():
"""
Example:
>>> from __future__ import print_function
>>> print 'Parse-Time Syntax Error'
"""
def demo_parsetime_syntax_error2():
"""
Example:
>>> def bad_syntax() return for
"""
def demo_runtime_error():
"""
Example:
>>> print('Runtime Error {}'.format(5 / 0))
"""
def demo_runtime_name_error():
"""
Example:
>>> print('Name Error {}'.format(foo))
"""
def demo_runtime_warning():
"""
Example:
>>> import warnings
>>> warnings.warn('in-code warning')
"""
if __name__ == '__main__':
"""
CommandLine:
python ~/code/xdoctest/dev/demo/demo_errors.py all
"""
import xdoctest
xdoctest.doctest_module(__file__)
|