FIX: Add infrastructure for python tests (#91)
Also integrated with CI and runs tests in documentation
This commit is contained in:
committed by
GitHub
parent
11df4a55c7
commit
bf9a1ed9f4
5
bindings/python/.gitignore
vendored
5
bindings/python/.gitignore
vendored
@@ -1,2 +1,5 @@
|
||||
target/*
|
||||
venv/*
|
||||
venv/*
|
||||
sphinx-venv/*
|
||||
html/*
|
||||
tests/__pycache*
|
||||
|
||||
8
bindings/python/docs/examples/simple.py
Normal file
8
bindings/python/docs/examples/simple.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import ironcalc as ic
|
||||
|
||||
model = ic.create("model", "en", "UTC")
|
||||
|
||||
model.set_user_input(0, 1, 1, "=21*2")
|
||||
model.evaluate()
|
||||
|
||||
assert model.get_formatted_cell_value(0, 1, 1), 42
|
||||
@@ -1,7 +1,13 @@
|
||||
Welcome to ProjectName's documentation!
|
||||
======================================
|
||||
IronCalc: The democratization of spreadsheets
|
||||
=============================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
IronCalc is a spreadsheet engine that allows you to create, modify and safe spreadsheets.
|
||||
|
||||
A simple example that creates a model, sets a formula, evaluates it and gets the result back:
|
||||
|
||||
.. literalinclude:: examples/simple.py
|
||||
:language: python
|
||||
29
bindings/python/run_examples.sh
Executable file
29
bindings/python/run_examples.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define the directory containing the Python files
|
||||
EXAMPLES_DIR="docs/examples"
|
||||
|
||||
# Check if the directory exists
|
||||
if [ ! -d "$EXAMPLES_DIR" ]; then
|
||||
echo "Directory $EXAMPLES_DIR does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Iterate over all Python files in the examples directory
|
||||
for file in "$EXAMPLES_DIR"/*.py; do
|
||||
# Check if there are any Python files
|
||||
if [ -f "$file" ]; then
|
||||
echo "Running $file..."
|
||||
python "$file"
|
||||
|
||||
# Check if the script ran successfully
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error running $file"
|
||||
else
|
||||
echo "$file ran successfully"
|
||||
fi
|
||||
else
|
||||
echo "No Python files found in $EXAMPLES_DIR"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
9
bindings/python/run_tests.sh
Executable file
9
bindings/python/run_tests.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
# not sure why this is needed
|
||||
pip install patchelf
|
||||
pip install maturin
|
||||
pip install pytest
|
||||
maturin develop
|
||||
pytest tests/
|
||||
8
bindings/python/tests/test_create.py
Normal file
8
bindings/python/tests/test_create.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import ironcalc as ic
|
||||
|
||||
def test_simple():
|
||||
model = ic.create("model", "en", "UTC")
|
||||
model.set_user_input(0, 1, 1, "=1+2")
|
||||
model.evaluate()
|
||||
|
||||
assert model.get_formatted_cell_value(0, 1, 1) == "3"
|
||||
Reference in New Issue
Block a user