Update 2015–09–14: Version 2.0.5 fixes all the regression bugs that have been found so far. Read on for the original story…

Green is a clean, colorful, fast test runner for Python unit tests.

After a ton of hard work, much of it by Sam Spilsbury, a generous code contributor, 2.0.0 is finally out!

The new major version has had its internals overhauled so that now test modules are run in parallel worker processes by default. There’s two important parts to that statement:

  1. “Test Modules” — In green’s multiprocess mode before now, worker processes processed at the individual test level. This resulted in lots and lots of duplicate overhead related to loading, setting up, and tearing down the test module and test cases. Now, by default, a single worker process runs an entire test module (which corresponds to all the tests in a single python file), which means that all of the overhead cost is only paid once by worker processes.
  2. “By Default” — Until now, the default mode for green was to run all tests sequentially in the main process, just like other boring, slow test runners. The reason behind this was that we wanted tests to “just work” out of the box when you switch to Green from whatever you started with. Since seemingly 99% of the concurrency bugs occur inside a test module, and we now run entire modules in the same worker process, we’ve side-stepped the issue. Hooray! Of course, if you threw all of your tests into a single module, you’ll want to split them up into multiple sensible modules to experience the speedup.

Click here for the full changelog.

I hope you’ll give Green a try at your unit test suite. If you don’t have unit tests for your Python code, now is a great time to start!

Written by

Nathan loves Rust, Python and Indie Game development. He is a veteran software developer (mostly backend infrastructure). He loves family, frisbee, food & fun.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store