Skip to content

Commit

Permalink
TST: use sybil for doctests (#178)
Browse files Browse the repository at this point in the history
* Use sybil for doctests

* Remove sphinx.ext.doctest

* Add docs/conftest.py

* Use sybil for all doctests and docs test

* Fix requirements

* Limit doctest precision

* Remove jupyter-sphinx extension

* Adjust documentation

* Use fixture for tmpdir

* Update docs
  • Loading branch information
hagenw authored Aug 14, 2024
1 parent 5f4a293 commit a9bc048
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 134 deletions.
11 changes: 11 additions & 0 deletions audinterface/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from doctest import ELLIPSIS
from doctest import NORMALIZE_WHITESPACE

from sybil import Sybil
from sybil.parsers.rest import DocTestParser


pytest_collect_file = Sybil(
parsers=[DocTestParser(optionflags=NORMALIZE_WHITESPACE + ELLIPSIS)],
patterns=["*.py"],
).pytest()
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
]
pygments_style = None
extensions = [
"jupyter_sphinx",
"sphinx.ext.napoleon", # support for Google-style docstrings
"sphinx_autodoc_typehints",
"sphinx.ext.viewcode",
Expand Down
29 changes: 29 additions & 0 deletions docs/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from doctest import ELLIPSIS
from doctest import NORMALIZE_WHITESPACE
import os

import pytest
from sybil import Sybil
from sybil.parsers.rest import DocTestParser
from sybil.parsers.rest import PythonCodeBlockParser


@pytest.fixture(scope="module")
def execute_in_tmpdir(tmpdir_factory):
path = tmpdir_factory.mktemp("doctest")
cwd = os.getcwd()
try:
os.chdir(path)
yield path
finally:
os.chdir(cwd)


pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=NORMALIZE_WHITESPACE + ELLIPSIS),
PythonCodeBlockParser(),
],
patterns=["*.rst"],
fixtures=["execute_in_tmpdir"],
).pytest()
6 changes: 0 additions & 6 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
audb
audeer
auditok
ipykernel
jupyter-sphinx
librosa
pyarrow
soxr >=0.4.0b1 # for numpy 2, https://github.com/dofuuz/python-soxr/issues/28
sphinx
sphinx-apipages >=0.1.2
sphinx-audeering-theme >=1.2.1
Expand Down
Loading

0 comments on commit a9bc048

Please sign in to comment.