Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a test suite for doctests #57

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cf/test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
from random import choice, shuffle
import unittest
import doctest
import pkgutil

import cf

Expand Down Expand Up @@ -42,6 +44,13 @@ def randomise_test_order(*_args):
shuffle(all_test_cases._tests)
testsuite.addTests(all_test_cases)

# Add a test suite for doctests
# https://docs.python.org/3/library/doctest.html#unittest-api
testsuite_doctests = unittest.TestSuite()
for importer, name, ispkg in \
pkgutil.walk_packages(cf.__path__, cf.__name__ + '.'):
Comment on lines +50 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more in line with PEP8 to avoid backslashes for line continuation, so as one minor comment I would suggest changing this as otherwise it might break our test running pycodestyle:

Suggested change
for importer, name, ispkg in \
pkgutil.walk_packages(cf.__path__, cf.__name__ + '.'):
for importer, name, ispkg in (
pkgutil.walk_packages(cf.__path__, cf.__name__ + '.')):

testsuite_doctests.addTests(doctest.DocTestSuite(name))

# Run the test suite's first set-up stage.
def run_test_suite_setup_0(verbosity=2):
runner = unittest.TextTestRunner(verbosity=verbosity)
Expand All @@ -54,6 +63,12 @@ def run_test_suite_setup_1(verbosity=2):
runner.run(testsuite_setup_1)


# Run the doctest test suite.
def run_test_suite_doctests(verbosity=2):
runner = unittest.TextTestRunner(verbosity=verbosity)
runner.run(testsuite_doctests)


# Run the test suite.
def run_test_suite(verbosity=2):
runner = unittest.TextTestRunner(verbosity=verbosity)
Expand All @@ -74,6 +89,7 @@ def run_test_suite(verbosity=2):

run_test_suite_setup_0()
run_test_suite_setup_1()
run_test_suite_doctests()
run_test_suite()

cf.CHUNKSIZE(original_chunksize)