Skip to main content

Generate mermaid / markdown sequence diagrams from your tests

Project description


This python package contains functions to instrument your code / tests to create sequence diagrams (in markdown / mermaid) as the tests run.

The sequence diagrams show the runtime call hierachy of the code. They are saved as files in the repository, which you should check in.

You can choose to ignore specific functions, and private functions, to make diagrams readable in each context you are interested in.

The diagrams are useful documentation, and will stay up to date as they are automatically generated. Hopefully it will encourage us to have useful diagrams in the repo, with the appropriate levels of detail, which in turn will encourage us to structure the code well so it produces good diagrams, and to have tests at these levels of detail.

You can see an example of this package in use at docs-from-tests-example.

Build Status

Build status


You can see an example of instrumenting a test at tests\

This test creates the following diagram

The diagram is reproduced here for convenience. It is a mermaid diagram, you may need to install a Browser Plugin or VsCode extension or similar to view it.

View full screen as SVG

  start->>HelloWorldCombiner.combine: calls x1
  HelloWorldCombiner.combine->>hello: calls x1
  hello-->>HelloWorldCombiner.combine: returns str
  HelloWorldCombiner.combine->>world: calls x1
  world-->>HelloWorldCombiner.combine: returns str
  HelloWorldCombiner.combine-->>start: returns str

Running tests

  • use python>=3.7
  • pip install requirements.txt
  • set pythonpath=<path to root of this repo>
  • pytest


  • Use PEP-0008
  • Please open up an Issue for new work, where any discussion can take place, and then submit a pull request to fix the issue.

Project Champion

The champion for this a repo is Cedd Burge who is accountable for:

  • The usability of the repo, and ensuring user guides and READMEs are up to date
  • The code quality of the repo (CODEOWNERS, pull requests, tests, and builds all help here)
  • The usability of the code for other developers (retrospectives, code quality, architecture, and documentation all help here)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docs_from_tests-0.0.2.tar.gz (4.1 kB view hashes)

Uploaded source

Built Distribution

docs_from_tests-0.0.2-py2-none-any.whl (5.0 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page