Skip to content

Commit 6fb0bd4

Browse files
committed
Refactored test works on pixi
1 parent 13b2b3d commit 6fb0bd4

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

pixi.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ matplotlib-base = ">=3.9"
3333
ipympl = ">=0.9"
3434
jupyterlab = ">=4.2"
3535
jupyterlab-myst = ">=2.4"
36+
pytest = ">=8.3.5,<9"
37+
nbval = ">=0.11.0,<0.12"
3638

3739
[pypi-dependencies]
3840
sphinx = ">=8.0.2"

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
norecursedirs = _build

test.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Collect converted ipynb files to clean up at the end.
4+
notebook_files=()
5+
6+
# Find Markdown files convert.
7+
all_markdown_files=$(find tutorials -type f -name "*.md")
8+
if [ $# -gt 0 ]; then
9+
files_to_process="$@"
10+
else
11+
files_to_process=$all_markdown_files
12+
fi
13+
14+
# Identify Markdown files that are Jupytext and convert them all.
15+
for file in ${files_to_process}; do
16+
echo loop in $file
17+
# Extract the kernel information from the Jupytext Markdown file.
18+
kernel_info=$(grep -A 10 '^---$' "$file" | grep -E 'kernelspec')
19+
# Skip if no kernel information was found.
20+
if [ -z "$kernel_info" ]; then
21+
continue
22+
fi
23+
# Convert to ipynb format, to be consumed by pytest nbval plugin.
24+
jupytext --to ipynb "$file"
25+
notebook_file="${file%.md}.ipynb"
26+
# Stash file in array to be cleaned up at the end.
27+
notebook_files+=("${notebook_file}")
28+
done
29+
30+
pytest --nbval-lax
31+
32+
# Clean up ipynb files that were converted. Any stray ipynb files that were
33+
# _not_ the result of conversion from Markdown will be left alone.
34+
for file in "${notebook_files[@]}"; do
35+
rm -v "$file"
36+
done

0 commit comments

Comments
 (0)