Skip to content

Commit d9f9279

Browse files
author
hhsecond
committed
tests using pytest
1 parent 48a90a9 commit d9f9279

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ jobs:
4646
REDIS_HOST: localhost
4747
REDIS_PORT: 6379
4848
run: |
49-
papermill scikit_learn/ScikitLearn2Production.ipynb -
49+
pytest test.py

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ entrypoints==0.3
1818
hiredis==1.0.0
1919
idna==3.3
2020
importlib-resources==5.4.0
21+
iniconfig==1.1.1
2122
ipykernel==6.5.1
2223
ipython==7.29.0
2324
ipython-genutils==0.2.0
@@ -54,14 +55,17 @@ pathspec==0.9.0
5455
pexpect==4.8.0
5556
pickleshare==0.7.5
5657
platformdirs==2.4.0
58+
pluggy==1.0.0
5759
prometheus-client==0.12.0
5860
prompt-toolkit==3.0.22
5961
protobuf==3.19.1
6062
ptyprocess==0.7.0
63+
py==1.11.0
6164
pycparser==2.21
6265
Pygments==2.10.0
6366
pyparsing==3.0.6
6467
pyrsistent==0.18.0
68+
pytest==6.2.5
6569
python-dateutil==2.8.2
6670
pytz==2021.3
6771
PyYAML==6.0
@@ -82,6 +86,7 @@ terminado==0.12.1
8286
testpath==0.5.0
8387
textwrap3==0.9.2
8488
threadpoolctl==3.0.0
89+
toml==0.10.2
8590
tomli==1.2.2
8691
tornado==6.1
8792
tqdm==4.62.3

test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import papermill as pm
2+
import os
3+
import glob
4+
import pytest
5+
6+
7+
def notebook_runner(notebook_path):
8+
"""
9+
This pytest function runs all the ipynb files in the repository
10+
using papermill - a notebook runner that throws if any exception occurs while executing the notebook
11+
"""
12+
# Run all the notebooks in the repository
13+
pm.execute_notebook(notebook_path, "-")
14+
15+
16+
17+
parameterizer = pytest.mark.parametrize("notebook_path", glob.glob(os.path.join(os.path.dirname(__file__), "*.ipynb")))
18+
# this variable (Which is a function) will be executed when pytest triggers the test
19+
test_notebooks = parameterizer(notebook_runner)

0 commit comments

Comments
 (0)