Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
cd dist
pip install -v pygambit*.tar.gz
- name: Run tests
run: pytest
run: pytest --run-tutorials

macos-13:
runs-on: macos-13
Expand All @@ -52,7 +52,6 @@ jobs:
python -m pip install --upgrade pip
pip install setuptools build cython wheel
pip install -r tests/requirements.txt
pip install -r doc/requirements.txt
- name: Build extension
run: |
python -m pip install -v .
Expand Down Expand Up @@ -82,7 +81,7 @@ jobs:
run: |
python -m pip install -v .
- name: Run tests
run: pytest
run: pytest --run-tutorials

windows:
runs-on: windows-latest
Expand All @@ -102,9 +101,9 @@ jobs:
python -m pip install --upgrade pip
pip install setuptools build cython wheel
pip install -r tests/requirements.txt
pip install nbformat nbclient ipykernel jupyter matplotlib
pip install -r doc/requirements.txt
- name: Build extension
run: |
python -m pip install -v .
- name: Run tests
run: pytest
run: pytest --run-tutorials
5 changes: 5 additions & 0 deletions doc/developer.contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ You can also run the tests locally before submitting your pull request, using `p

pytest

3. [Optional] If you wish to run the tutorial notebook tests, you will need to add the ``--run-tutorials`` flag, which require the `doc` dependencies: ::

pip install -r doc/requirements.txt
pytest --run-tutorials

Adding to the test suite
^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ipython
matplotlib
pickleshare
jupyter
open_spiel
open_spiel; sys_platform != 'win32'
33 changes: 33 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest


def pytest_addoption(parser):
parser.addoption(
"--run-tutorials",
action="store_true",
default=False,
help="Run tutorial notebook tests",
)


def pytest_configure(config):
config.addinivalue_line(
"markers", "tutorials: mark test as a tutorial notebook test"
)


def pytest_collection_modifyitems(config, items):
if config.getoption("--run-tutorials"):
# --run-tutorials given in cli: do not skip tutorial tests
return

# Check if test_tutorials.py was explicitly specified
args = config.invocation_params.args
if any("test_tutorials.py" in str(arg) for arg in args):
# test_tutorials.py explicitly run: do not skip
return

skip_tutorials = pytest.mark.skip(reason="need --run-tutorials option to run")
for item in items:
if "tutorials" in item.keywords:
item.add_marker(skip_tutorials)
1 change: 1 addition & 0 deletions tests/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def _find_tutorial_notebooks():
_NOTEBOOKS = _find_tutorial_notebooks()


@pytest.mark.tutorials
@pytest.mark.parametrize("nb_path", _NOTEBOOKS, ids=[p.name for p in _NOTEBOOKS])
def test_execute_notebook(nb_path):
"""Execute a single Jupyter notebook and fail if any cell errors occur.
Expand Down
Loading