Skip to content

Commit

Permalink
update example testing and add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienDoerner committed Oct 27, 2023
1 parent e651bcf commit cb02918
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
f=(${file//// })
f=${f[1]}
f=(${f//./})
finalFile="$runfolder"/"$f".py
echo "convert notebook $file to script $finalFile"
jupyter nbconvert --to python "$file" --stdout | grep -v -e "^get_ipython" > "$runfolder"/"$f".py
fi
done
Expand All @@ -57,9 +59,8 @@ jobs:
runfolder: "notebook_run"
run: |
cd "$runfolder"
python3 -c "from sys import path; print(path)"
python3 -c "from crpropa import c_light"
for file in ./*.py; do
ls
for file in *.py; do
if [ -f "$file" ]; then
python3 "$file"
fi
Expand Down
53 changes: 53 additions & 0 deletions doc/pages/example_notebooks/basics/failing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "RuntimeError",
"evalue": "this notebook should not succeed",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/home1/jdo/CRPropa3/doc/pages/example_notebooks/basics/faining.ipynb Zelle 1\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2Bk10/home/home1/jdo/CRPropa3/doc/pages/example_notebooks/basics/faining.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mRuntimeError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mthis notebook should not succeed\u001b[39m\u001b[39m\"\u001b[39m)\n",
"\u001b[0;31mRuntimeError\u001b[0m: this notebook should not succeed"
]
}
],
"source": [
"raise RuntimeError(\"this notebook should not succeed\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit cb02918

Please sign in to comment.