Skip to content

#60: Change the Look & Feel of Pytest With Pytest-Sugar

If you get bored by the dots in the pytest test-runner you may be interested in the pytest-sugar plugin. Let us look what it does and how you can get it.

Installation

You can install pytest-sugar with PIP:

pip install pytest-sugar

Run pytest

You can run pytest as usual and pytest-sugar will do its magic in the background. There are no command line options necessary:

$ pytest

Instead of the boring dots you now get checkmarks and a progress-bar:

pytest-sugar in action Source: pytest-sugar on GitHub

If one of your tests fail, you get the error message immediately and do not need to wait until pytest finishes.

Disable pytest-sugar

If you do not want to use pytest-sugar you can turn it off with this option:

$ pytest -p no:sugar

Conclusion

Pytest-sugar is a nice little addition to the test runner. It is not a necessity, but it makes watching pytest checking your software a little bit more interesting and you get errors faster.