Skip to content

Commit

Permalink
tests: docs: Move notebook tests under docs
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <johnandersenpdx@gmail.com>
  • Loading branch information
pdxjohnny committed Aug 17, 2021
1 parent 27757f6 commit 051577b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test_no_skips() {
TEMP_DIRS+=("${check_skips}")

# Run with coverage
RUN_CONSOLETESTS=1 "${PYTHON}" -u -m coverage run -m unittest discover -v 2>&1 | tee "${check_skips}"
TEST_DOCS=1 "${PYTHON}" -u -m coverage run -m unittest discover -v 2>&1 | tee "${check_skips}"
"${PYTHON}" -m coverage report -m

# Fail if any coroutines were not awaited
Expand Down Expand Up @@ -136,7 +136,7 @@ function run_consoletest() {
# Install base package with testing and development utilities
"${PYTHON}" -m pip install -U -e ".[dev]"

RUN_CONSOLETESTS=1 "${PYTHON}" -u -m unittest "tests.docs.test_consoletest.TestDocs.test_${PLUGIN}" 2>&1 | tee "${test_log}"
TEST_DOCS=1 "${PYTHON}" -u -m unittest "tests.docs.test_consoletest.TestDocs.test_${PLUGIN}" 2>&1 | tee "${test_log}"

# Fail if any coroutines were not awaited
unawaited=$(grep -nE 'coroutine .* was never awaited' "${test_log}" | wc -l)
Expand Down
6 changes: 6 additions & 0 deletions docs/contributing/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ You can also run all tests which have a given string in their name.
$ python3 -m unittest discover -v -k unpack_
You can run all documentation related testcases with the following command

.. code-block:: console
$ TEST_DOCS=1 python3 -m unittest discover -v tests/docs/
Writing Tests
-------------

Expand Down
6 changes: 3 additions & 3 deletions tests/docs/test_consoletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ def pickle_load(fileobj):
if str(relative) not in NO_SETUP:
# Don't check for a long test entry in the workflow if doc in NO_SETUP
TestDocs.TESTABLE_DOCS.append(str(relative))
# Skip if not in NO_SETUP and RUN_CONSOLETESTS not set
# Skip if not in NO_SETUP and TEST_DOCS not set
testcase = unittest.skipIf(
"RUN_CONSOLETESTS" not in os.environ,
"RUN_CONSOLETESTS environment variable not set",
"TEST_DOCS" not in os.environ,
"TEST_DOCS environment variable not set",
)(testcase)
# Do not add the tests if we are running with GitHub Actions for the main
# package. This is because there are separate jobs for each tutorial test
Expand Down
7 changes: 6 additions & 1 deletion tests/test_notebooks.py → tests/docs/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dffml.util.asynctestcase import AsyncTestCase
from dffml.util.os import chdir

TESTS_PATH = pathlib.Path(__file__).parent
TESTS_PATH = pathlib.Path(__file__).parents[1]
NOTEBOOK_DATA_PATH = TESTS_PATH.joinpath("notebooks", "data")
NB_PATH = TESTS_PATH.parent / "examples" / "notebooks"

Expand All @@ -32,6 +32,11 @@ def testcase(self):
with testbook(path, timeout=-1, execute=True) as tb:
pass

testcase = unittest.skipIf(
"TEST_DOCS" not in os.environ,
"TEST_DOCS environment variable not set",
)(testcase)

return testcase


Expand Down

0 comments on commit 051577b

Please sign in to comment.