-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update setup.py and restructure \"run unittests\" stuff
- Loading branch information
Showing
4 changed files
with
154 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,129 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
""" | ||
run all unittests | ||
~~~~~~~~~~~~~~~~~ | ||
:copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. | ||
:license: GNU GPL v3 or above, see LICENSE for more details. | ||
""" | ||
|
||
from __future__ import division, absolute_import, print_function, unicode_literals | ||
|
||
from doctest import testmod | ||
import os | ||
import sys | ||
import time | ||
import unittest | ||
|
||
from . import run_all_tests as all_tests | ||
import creole | ||
from creole.tests import all_tests | ||
|
||
|
||
SKIP_DIRS = (".settings", ".git", "dist", "python_creole.egg-info") | ||
SKIP_FILES = ("setup.py", "test.py") | ||
|
||
|
||
if "-v" in sys.argv or "--verbosity" in sys.argv: | ||
VERBOSE = 2 | ||
elif "-q" in sys.argv or "--quite" in sys.argv: | ||
VERBOSE = 0 | ||
else: | ||
VERBOSE = 1 | ||
|
||
|
||
def run_all_doctests(verbosity=None): | ||
""" | ||
run all python-creole DocTests | ||
""" | ||
start_time = time.time() | ||
if verbosity is None: | ||
verbosity = VERBOSE | ||
|
||
path = os.path.abspath(os.path.dirname(creole.__file__)) | ||
if verbosity >= 2: | ||
print("") | ||
print("_" * 79) | ||
print("Running %r DocTests:\n" % path) | ||
|
||
total_files = 0 | ||
total_doctests = 0 | ||
total_attempted = 0 | ||
total_failed = 0 | ||
for root, dirs, filelist in os.walk(path, followlinks=True): | ||
for skip_dir in SKIP_DIRS: | ||
if skip_dir in dirs: | ||
dirs.remove(skip_dir) # don't visit this directories | ||
|
||
for filename in filelist: | ||
if not filename.endswith(".py"): | ||
continue | ||
if filename in SKIP_FILES: | ||
continue | ||
|
||
total_files += 1 | ||
|
||
def run_all_tests(): | ||
sys.path.insert(0, root) | ||
try: | ||
m = __import__(filename[:-3]) | ||
except ImportError as err: | ||
if verbosity >= 2: | ||
print("***DocTest import %s error*** %s" % (filename, err)) | ||
except Exception as err: | ||
if verbosity >= 2: | ||
print("***DocTest %s error*** %s" % (filename, err)) | ||
else: | ||
failed, attempted = testmod(m) | ||
total_attempted += attempted | ||
total_failed += failed | ||
if attempted or failed: | ||
total_doctests += 1 | ||
|
||
if attempted and not failed: | ||
filepath = os.path.join(root, filename) | ||
if verbosity <= 1: | ||
sys.stdout.write(".") | ||
elif verbosity >= 2: | ||
print("DocTest in %s OK (failed=%i, attempted=%i)" % ( | ||
filepath, failed, attempted | ||
)) | ||
finally: | ||
del sys.path[0] | ||
|
||
duration = time.time() - start_time | ||
print("") | ||
print("-"*70) | ||
print("Ran %i DocTests from %i files in %.3fs: failed=%i, attempted=%i\n\n" % ( | ||
total_doctests, total_files, duration, total_failed, total_attempted | ||
)) | ||
|
||
|
||
|
||
def get_test_suite(): | ||
""" | ||
return the unittest.TestSuite for setup.py | ||
""" | ||
suite = unittest.findTestCases(all_tests) | ||
return suite | ||
|
||
|
||
def run_unittests(verbosity=None): | ||
""" | ||
run all python-creole unittests | ||
""" | ||
if verbosity is None: | ||
verbosity = VERBOSE | ||
|
||
if verbosity >= 2: | ||
print("") | ||
print("_" * 79) | ||
print("Running Unittests:\n") | ||
|
||
unittest.main(verbosity=verbosity) | ||
|
||
|
||
if __name__ == '__main__': | ||
run_all_doctests() | ||
run_unittests() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
""" | ||
run all unittests | ||
~~~~~~~~~~~~~~~~~ | ||
:copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. | ||
:license: GNU GPL v3 or above, see LICENSE for more details. | ||
""" | ||
|
||
from __future__ import division, absolute_import, print_function, unicode_literals | ||
|
||
from creole.tests.test_creole2html import TestCreole2html, TestCreole2htmlMarkup, TestStr2Dict, TestDict2String | ||
from creole.tests.test_cross_compare_all import CrossCompareTests | ||
from creole.tests.test_cross_compare_creole import CrossCompareCreoleTests | ||
from creole.tests.test_cross_compare_rest import CrossCompareReStTests | ||
from creole.tests.test_cross_compare_textile import CrossCompareTextileTests | ||
from creole.tests.test_html2creole import TestHtml2Creole, TestHtml2CreoleMarkup | ||
from creole.tests.test_rest2html import ReSt2HtmlTests | ||
from creole.tests.test_setup_utils import SetupUtilsTests | ||
from creole.tests.test_utils import UtilsTests | ||
from creole.tests.utils.utils import MarkupTest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters