diff options
author | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-03-07 14:05:52 -0800 |
---|---|---|
committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-03-07 14:05:52 -0800 |
commit | 42b22881290e00e06b840dee1e42f0f5ef044d47 (patch) | |
tree | b4fef928625acd3e8ee45ccaa8c7a6c9810b3601 /tests/test_doctests.py | |
download | paste-git-tox_add_py35.tar.gz |
tox.ini: Add py35 to envlisttox_add_py35
Diffstat (limited to 'tests/test_doctests.py')
-rw-r--r-- | tests/test_doctests.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test_doctests.py b/tests/test_doctests.py new file mode 100644 index 0000000..d59d666 --- /dev/null +++ b/tests/test_doctests.py @@ -0,0 +1,63 @@ +import six +import doctest +from paste.util.import_string import simple_import +import os + +filenames = [ + 'tests/test_template.txt', + ] + +modules = [ + 'paste.util.template', + 'paste.util.looper', + # This one opens up httpserver, which is bad: + #'paste.auth.cookie', + #'paste.auth.multi', + #'paste.auth.digest', + #'paste.auth.basic', + #'paste.auth.form', + #'paste.progress', + 'paste.exceptions.serial_number_generator', + 'paste.evalexception.evalcontext', + 'paste.util.dateinterval', + 'paste.util.quoting', + 'paste.wsgilib', + 'paste.url', + 'paste.request', + ] + +options = doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE +if six.PY3: + options |= doctest.IGNORE_EXCEPTION_DETAIL + +def test_doctests(): + for filename in filenames: + filename = os.path.join( + os.path.dirname(os.path.dirname(__file__)), + filename) + yield do_doctest, filename + +def do_doctest(filename): + failure, total = doctest.testfile( + filename, module_relative=False, + optionflags=options) + assert not failure, "Failure in %r" % filename + +def test_doctest_mods(): + for module in modules: + yield do_doctest_mod, module + +def do_doctest_mod(module): + module = simple_import(module) + failure, total = doctest.testmod( + module, optionflags=options) + assert not failure, "Failure in %r" % module + +if __name__ == '__main__': + import sys + import doctest + args = sys.argv[1:] + if not args: + args = filenames + for filename in args: + doctest.testfile(filename, module_relative=False) |