What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To run Python tests in PyCharm, choose a test runner for your project interpreter, then start a run from the gutter or the context menu on the test you want. Results appear in the Test Runner tab as a tree you can navigate, and coverage is a separate run mode you start with Run with Coverage. The steps below follow the PyCharm 2026.2 documentation, and menu labels can shift between releases.

Confirm the interpreter and install your test framework

PyCharm builds its test commands from the interpreter you have configured for the project, so start there. Install the framework you plan to use into that same interpreter. If you use pytest, it must be installed in the selected interpreter before PyCharm can offer it as a runner. Installing it in a different Python environment is the most common reason pytest seems to be missing.

Set the default test runner

The default runner is a project-level setting. To check or change it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Open Settings → Python → Tools → Integrated Tools.
  2. Select the default runner from the list. Choose pytest if the project uses it, or unittest for the standard library framework.

PyCharm auto-detects installed runners. If no specific runner is installed, it falls back to unittest. If the runner you selected is not installed in the project interpreter, PyCharm can show a notification saying so, which is your cue to install it and try again.

The default runner does not override a run/debug configuration that already exists for a particular file and framework. If a test still launches with the old runner after you change the setting, check for a saved configuration for that test.

Run a single test

Start from the test itself, not from a separate run dialog. PyCharm offers two entry points:

From the gutter

Click the run icon that appears in the gutter beside a test function or class in the editor. This runs that test only.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

From the context menu

Right-click the test in the editor, or the file in the Project tool window, and choose Run. The menu entry names the test target, which helps you confirm you picked the right one.

When no matching run configuration exists, PyCharm creates a temporary one and runs it immediately. Temporary configurations are convenient for a quick check but are replaced on the next launch. If you expect to rerun the same target, save the configuration so you can reuse it and adjust its arguments later.

Run a file, class, or directory

The scope of a run is whatever you select when you launch it. A single test, a test file, a class, or a whole directory can each serve as the run target. The same selection logic applies when you launch from the Project tool window.

For repeated runs over a broader scope, use a saved pytest configuration. A pytest run configuration can target a script, a module, or a custom combination of targets, and it accepts additional arguments. Reusing a saved configuration is also the cleanest way to keep the same scope from run to run. The Run tests page covers the entry points and configuration options in detail.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read results in the Test Runner tab

The Test Runner tab shows the test hierarchy, the status of each node, the test output, and inline timing information. Use the tree to find a failing test and open it in the editor. Expanding a node shows the tests beneath it, so a failing directory can be narrowed down to the file and function that broke.

The Test Runner tab documentation describes each part of the view. Reading the output pane alongside the tree is usually faster than scrolling the console when a test fails.

Debug tests and handle pytest-cov interference

Running a test under the debugger works the same way as a normal run, but a pytest-cov plugin in the environment can occasionally interfere with debugging. JetBrains documents a targeted fix: add --no-cov -s to the Additional Arguments field of the pytest run configuration. Use it when debugging misbehaves because of coverage, not as a standard setting for every pytest run. The Pytest run/debug configuration page explains the fields.

Collect test coverage

Coverage is a separate run mode. Choose Run with Coverage from the run configuration, the Project view, or the editor, depending on where you start the run. The collected data is shown alongside the test results, and the coverage settings control how that data is applied to the active suites.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See Running with coverage for the launch steps and the Coverage page for how collected data is handled. Because coverage is a run mode rather than a result filter, a normal run will not produce coverage data.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Optional: parallel runs and commit checks

Once the basic workflow is comfortable, two optional features are worth knowing about.

  • Parallel execution with pytest-xdist. PyCharm can run pytest tests in parallel using pytest-xdist, with the -n argument set to the number of CPUs you want to use. Parallel runs can consume noticeably more CPU and memory, so start with a modest number on a shared machine.
  • Commit checks. PyCharm documents commit checks for Git and Mercurial, which can run tests as part of committing. Treat this as an option you enable deliberately, since a slow suite will slow every commit.

Both features are described on the Run tests page.

Choose the framework your project already uses

There is no single best runner in PyCharm. The right choice is the framework your project already uses, because that determines which run and debug integration is available. The official Testing frameworks page lists unittest, pytest, nose, tox, Twisted Trial, and doctests, and the level of support differs between them. When you compare options, look at:

  • Whether the framework is already a dependency of the project.
  • Which run and debug integration it supports in PyCharm.
  • Whether you need pytest-specific fixtures or parallel execution.
  • Edition: BDD framework support is marked as available only in PyCharm Pro.

Troubleshooting

  • The expected runner is missing. Confirm it is installed in the interpreter selected for the project, then reselect it in Settings → Python → Tools → Integrated Tools.
  • Tests run with a different runner than the one you chose. Look for an existing run/debug configuration for that file or framework. It takes precedence over the default runner.
  • Debugging behaves oddly with coverage enabled. Add --no-cov -s to Additional Arguments in the pytest run configuration, as described above.
  • Results are empty after a run. Check that the scope you selected actually contains tests the chosen runner can discover.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.