2

This is a how-to/best-practice question.

  • I have a code base with a suite of unit tests run with pytest
  • I have a set of *.rst files which provide explanation of each test, along with a table of results and images of some mathematical plots
  • Each time the pytest suite runs, it dynamically updates the *.rst files with the results of the latest test data, updating numerical values, time-stamping the tests, etc

I would like to integrate this with the project docs. I could

  • Build these rst files separately with sphinx-build whenever I want to view the test results [this seems bad, since it's labor intensive and not automated]
  • tell Sphinx to render these pages separately and include them in the project docs [better, but I'm not sure how to configure this]
  • have a separate set of sphinx docs for the test results which I can build after each run of the test suite

Which approach (or another approach) is most effective? Is there a best practice for doing this type of thing?

barryhunter
  • 20,886
  • 3
  • 30
  • 43
user3482876
  • 249
  • 2
  • 11

1 Answers1

1

Maybe take a look into Sphinx-Test-Reports, which reads in all information from junit-based xml-files (pytest supports this) and generates the output during the normal sphinx build phase.

So you are free to add custom information around the test results.

Example from webpage:

.. test-report:: My Report
   :id: REPORT
   :file: ../tests/data/pytest_sphinx_data_short.xml

So complete answer to your question: Take none of the given approaches and let a sphinx-extension do it during build-time.

danwos
  • 416
  • 3
  • 12