Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit e4da41b

Browse files
committed
tests: docs: Move notebook tests under docs
Signed-off-by: John Andersen <johnandersenpdx@gmail.com>
1 parent c531444 commit e4da41b

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

.ci/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test_no_skips() {
3838
TEMP_DIRS+=("${check_skips}")
3939

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

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

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

141141
# Fail if any coroutines were not awaited
142142
unawaited=$(grep -nE 'coroutine .* was never awaited' "${test_log}" | wc -l)

docs/contributing/testing.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ You can also run all tests which have a given string in their name.
2323
2424
$ python3 -m unittest discover -v -k unpack_
2525
26+
You can run all documentation related testcases with the following command
27+
28+
.. code-block:: console
29+
30+
$ TEST_DOCS=1 python3 -m unittest discover -v tests/docs/
31+
2632
Writing Tests
2733
-------------
2834

tests/docs/test_consoletest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ def pickle_load(fileobj):
173173
if str(relative) not in NO_SETUP:
174174
# Don't check for a long test entry in the workflow if doc in NO_SETUP
175175
TestDocs.TESTABLE_DOCS.append(str(relative))
176-
# Skip if not in NO_SETUP and RUN_CONSOLETESTS not set
176+
# Skip if not in NO_SETUP and TEST_DOCS not set
177177
testcase = unittest.skipIf(
178-
"RUN_CONSOLETESTS" not in os.environ,
179-
"RUN_CONSOLETESTS environment variable not set",
178+
"TEST_DOCS" not in os.environ,
179+
"TEST_DOCS environment variable not set",
180180
)(testcase)
181181
# Do not add the tests if we are running with GitHub Actions for the main
182182
# package. This is because there are separate jobs for each tutorial test

tests/test_notebooks.py renamed to tests/docs/test_notebooks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from dffml.util.asynctestcase import AsyncTestCase
1010
from dffml.util.os import chdir
1111

12-
TESTS_PATH = pathlib.Path(__file__).parent
12+
TESTS_PATH = pathlib.Path(__file__).parents[1]
1313
NOTEBOOK_DATA_PATH = TESTS_PATH.joinpath("notebooks", "data")
1414
NB_PATH = TESTS_PATH.parent / "examples" / "notebooks"
1515

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

35+
testcase = unittest.skipIf(
36+
"TEST_DOCS" not in os.environ,
37+
"TEST_DOCS environment variable not set",
38+
)(testcase)
39+
3540
return testcase
3641

3742

0 commit comments

Comments
 (0)