-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
4 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
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
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,44 @@ | ||
from __future__ import absolute_import, print_function | ||
|
||
import doctest | ||
import fnmatch | ||
import importlib | ||
import os | ||
import pkgutil | ||
|
||
import fuel | ||
from tests import skip_if_not_available | ||
|
||
|
||
def setup(testobj): | ||
skip_if_not_available(modules=['nose2']) | ||
# Not importing unicode_literal because it gives problems | ||
# If needed, see https://dirkjan.ochtman.nl/writing/2014/07/06/ | ||
# single-source-python-23-doctests.html for a solution | ||
testobj.globs['absolute_import'] = absolute_import | ||
testobj.globs['print_function'] = print_function | ||
|
||
|
||
def load_tests(loader, tests, ignore): | ||
# This function loads doctests from all submodules and runs them | ||
# with the __future__ imports necessary for Python 2 | ||
for _, module, _ in pkgutil.walk_packages(path=fuel.__path__, | ||
prefix=fuel.__name__ + '.'): | ||
try: | ||
tests.addTests(doctest.DocTestSuite( | ||
module=importlib.import_module(module), setUp=setup, | ||
optionflags=doctest.IGNORE_EXCEPTION_DETAIL)) | ||
except: | ||
pass | ||
|
||
# This part loads the doctests from the documentation | ||
docs = [] | ||
for root, _, filenames in os.walk(os.path.join(fuel.__path__[0], | ||
'../docs')): | ||
for doc in fnmatch.filter(filenames, '*.rst'): | ||
docs.append(os.path.abspath(os.path.join(root, doc))) | ||
tests.addTests(doctest.DocFileSuite( | ||
*docs, module_relative=False, setUp=setup, | ||
optionflags=doctest.IGNORE_EXCEPTION_DETAIL)) | ||
|
||
return tests |