Skip to content

doconce/doconce_tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

doconce_tests

This repository contains a test suite and is a git-submodule of the DocOnce project.

Table of Contents

Synching tests in doconce

After cloning the main doconce repository, the content of this repository (and all other git-submodule) can be downloaded by running this command:

git submodule update --init

Requirements

The basic requirements are listed for the main doconce repository. In addition, some tests are run using Jupyter kernels, but only if their installation is detected.

You can list the currently installed kernels with this command: jupyter kernelspec list.

Tests for DocOnce

There are three types of tests:

  • regression suite in tests.py
  • unit tests in pytests.py
  • unit tests in test_mintest.py

tests.py

The first contains classical regression tests where text is generated in many files, these are concatenated, and then compared with the big reference file with name test.r.

This is run by:

python tests.py

A diff test.v test.r show differences of generated text (test.v) and reference data (test.r). Don't run this unless you have a complete installation with all the DocOnce dependencies.

pytests.py

The unit tests in pytests.py can be run with:

pip install pytest pytest pytests.py

These tests are run in the GitHub Actions workflow in the DocOnce GitHub repository.

Troubleshooting pytests

To execute a single test e.g. test_doconce_format_execute in pytests.py:

pytest -v --pdb pytests.py::test_doconce_format_execute

where -v is the verbose optionand --pdb opens the debugger on the first failure.

The following plugin allowing pytest to terminate executionwhen tests take too long:

pip install pytest-timeout pytest --timeout=12 --timeout_method=thread --pdb pytests.py::test_doconce_format_execute

The -s flag is equivalent to --capure=no and it allows to see in the terminal any print statements present in the code

pytest -s pytests.py::test_doconce_format_execute

test_mintest.py

The plain unit tests are in test_mintest.py (very minimalistic tests, mainly to check that the installation of DocOnce itself is okay). Run by

py.test test_mintest.py

Requirements

A complete installation of DocOnce. In addition some tests are run on features not included in the DocOnce standard requirements, for example Jupyter Julia and Bash kernels.

Notes

Note that standard unit tests with nose/pytest are less suitable for a text transformation program such as DocOnce. The reason is that some functionality must be tested in larger files where many constructions play together. Also, test files are frequently changed to add new constructions, or test the effect of bug fixes, leading to a substantial evolution of the reference text. At least for a small project as DocOnce, this has turned out to be the most feasible testing approach. Basically, python test.py is run and test.v is compared against test.r in a diff program, using the human eye (because many updates lead to significant changes in the diff that require a human to approve).

Dependencies for the test problems run by test.py are basically all software that DocOnce depends on, see installation instructions in ../doc/pub/manual/manual.html.