This module implements pytest plugin for Sphinx doc tests.
In a nutshell, it uses the pytest pytest_collect_file() plugin hook to recognize the Sphinx Makefile. Then it does a quick and dirty parse of that Makefile to extract the command Sphinx is using to run the doctests, which it recognizes by being the first command in the Makefile target named by SPHINX_DOCTEST_TARGET. The parser is able to handle simple Makefile variable expansion, though not currently nested variables so don’t do that.
The mechanics of the pytest plugin mechanism are such that the Makefile
is wrapped with a subclass of
which implements the collect method to yield a subclass of
SphinxItem, that in turn implements a few methods to run the
test and report the result. The bulk of the code in running the test is parsing
the output to look for errors, and thus decide whether all the doctests passed,
The drawback of this whole setup is of course some extra complexity. The advantage is that (a) whatever the Makefile does is what this plugin should do, for running the command, as long as the command is the first (and only significant) thing that occurs in the target, and (b) if there ends up being more than one Makefile, it should all continue to work.
SphinxDoctestItem(name, parent, wd, cmd)
SphinxDoctestSuccess(name, parent=None, config=None, session=None, nodeid=None)
SphinxMakefile(fspath, parent=None, config=None, session=None, nodeid=None)
Get warnings and errors output file, if any, from the Sphinx Makefile.
SphinxWarnings(fspath, parent=None, config=None, session=None, nodeid=None)
Utility code for testing IDAES code.
This script downloads a python file from pyomo.org that will allow us to update the workshop material easily during a workshop.
- The file install_idaes_workshop_materials.py is downloaded from pyomo.org, imported,
- and the method execute() is then called to do whatever actions are necessary.
Note: - update_workshop_materials.py is a module in the idaes/util folder that does the work - update_workshop_materials.ipynb is a Jupyter notebook in the examples/workshops folder
that calls this module
- install_idaes_workshop_materials.py is posted on a site (for now pyomo.org, but later could be a repository on github).
- JupyterHub: User executes update_workshop_materials.ipynb which calls to update_workshop_materials.py in idaes/util
- update_workshop_materials.py downloads another python file (install_idaes_workshop_materials.py) from pyomo.org and calls “execute()” from that module.
- install_idaes_workshop_materials.py does whatever is necessary to get the workshop materials into the user folder (and perform any updates necessary).
TODO: This should probably be changed to get a zip file from an IDAES repository rather than install_idaes_workshop_materials.py from pyomo.org
Downloads install_idaes_workshop_materials.py from pyomo.org