Fabian Deutsch has uploaded a new change for review. Change subject: Use nosetest for doctests ......................................................................
Use nosetest for doctests The problems with doctests is that relative imports don't work with python -m doctest. But nosetest can run doctests and handle relative imports. Change-Id: I48d2f50b3dad24aa94d27d9abaabb74402149046 Signed-off-by: Fabian Deutsch <[email protected]> --- M src/Makefile.check D src/autotest.py M tests/Makefile.am 3 files changed, 2 insertions(+), 59 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/10/43010/1 diff --git a/src/Makefile.check b/src/Makefile.check index 802b77a..c516d84 100644 --- a/src/Makefile.check +++ b/src/Makefile.check @@ -22,7 +22,7 @@ @echo Passed $@ %.doctest: - python $(top_srcdir)/src/autotest.py $* + nosetests -q --with-doctest $* check-static-pep8: $(PYTHONSOURCES:%=%.pep8) @echo Passed $@ diff --git a/src/autotest.py b/src/autotest.py deleted file mode 100755 index a1cb865..0000000 --- a/src/autotest.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python2 -# -# Copyright (C) 2014, Red Hat, Inc. -# Written by Ryan Barry <[email protected]> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Convenience wrapper around doctest -import argparse -import doctest -import sys -import re -import os -import traceback - -def test(): - parser = argparse.ArgumentParser(description="Runs doctests on a file") - parser.add_argument('FILE') - arguments = parser.parse_args() - - testable = False - for line in open(arguments.FILE): - if ">>>" in line: - testable = True - - if not testable: - return 0 - - else: - mod = re.sub(r'\/', r'.', os.path.splitext(arguments.FILE)[0]) - try: - test = __import__(mod, globals(), locals(), ['object'], -1) - failures,tests = doctest.testmod(test) - if failures > 0: - print "Failures from %s: %s" % (mod, failures) - return -1 - else: - return 0 - except ImportError: - traceback.print_exc() - print "Failed to import %s" % arguments.FILE - return -1 - - -if __name__ == "__main__": - sys.exit(test()) diff --git a/tests/Makefile.am b/tests/Makefile.am index b8582ad..31f2f41 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,7 +22,7 @@ .PHONY: %.junit.xml -check-local: unittests +check: unittests @echo -e "---\n Passed $@\n---" unittests: $(PYTHONUNITTESTS:%=%.nose) -- To view, visit https://gerrit.ovirt.org/43010 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I48d2f50b3dad24aa94d27d9abaabb74402149046 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: master Gerrit-Owner: Fabian Deutsch <[email protected]> Gerrit-Reviewer: Fabian Deutsch <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
