-
Notifications
You must be signed in to change notification settings - Fork 848
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
1 parent
b1b08ac
commit a389bb9
Showing
2 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from collections.abc import Iterable | ||
from pathlib import Path | ||
|
||
from testbook import testbook | ||
|
||
TIMEOUT: int = 60 | ||
|
||
ROOT_DIRECTORY = Path(__file__).parent | ||
|
||
|
||
def test_notebooks(): | ||
for notebook_path in _get_notebooks(): | ||
with testbook(notebook_path, execute=True, timeout=TIMEOUT) as tb: | ||
pass # we simply wish it to run without errors | ||
|
||
|
||
def _get_notebooks() -> Iterable[str]: | ||
if os.environ.get("SHOULD_TEST_ALL_FILES", "") == "true": | ||
notebooks_to_test = _get_all_notebooks() | ||
else: | ||
if os.environ.get("HAS_ANY_IPYNB_CHANGED", "") == "true": | ||
notebooks_to_test = os.environ.get("LIST_OF_IPYNB_CHANGED", "").split() | ||
else: | ||
notebooks_to_test = [] | ||
|
||
return notebooks_to_test | ||
|
||
|
||
def _get_all_notebooks(directory=ROOT_DIRECTORY): | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
if file.endswith(".ipynb"): | ||
yield os.path.join(root, file) |