Link Search Menu Expand Document

unittest + YourBase

On this page you’ll learn how to accelerate your unittest tests with YourBase. For a more in-depth acceleration walkthrough using a sample project, see our pytest page.

Table of contents

  1. Prerequisites
  2. Enable acceleration for your project


  • Make sure tests are running successfully with unittest before installing YourBase.
  • Install YourBase.
  • Your project must use Git and must have at least one commit. Git must be installed.
  • Your Git workspace should be clean.

Enable acceleration for your project

Step 1: Attach yourbase to unittest

In your tests/ file, copy-paste the following:

import unittest
import yourbase


Step 2: Run your project’s tests

For example, to run all the tests for the project, use:

python -m unittest discover

Note: If your tests are going to take a while to run, you can run just a subset of your tests. Running a subset of tests will create a dependency graph just for those tests, so you can see YourBase Test Acceleration in action more quickly.

Step 3: Re-run your tests

Without making a code change, run your tests again using the same command as in step 2.

You’ll see that no tests are run. Since no code was changed since the last test run, YourBase Test acceleration ensures that no tests are run.

Step 4: Make a code change that would affect a test

We’ve seen that YourBase can skip tests when they’re not affected by code changes. Let’s now see that it can run tests when they are!

Make a change to a function that gets called (directly or indirectly) by one or more tests. The change can be as simple as adding a print statement like:

print("Checking YourBase Test Acceleration after a code change...")

Step 5: Run your tests again

Use the same command as in [step 1][step-1] to run your tests. Here, YourBase Test acceleration ensures the tests that depend on the changed function run, and others don’t.