Free tools Windows power users keep installed
One-click scans. No signup required.
To run Python tests in PyCharm, make sure the project uses the interpreter where your test framework is installed, choose the project’s default runner, then launch a test from the editor gutter or Project tool window. PyCharm opens the results in the Test Runner tab; you can run a single test or expand the target to a file, class, or directory.
1. Check the project interpreter and test framework
PyCharm’s test commands depend on the project interpreter and configured runner. First confirm the interpreter assigned to the project, then check that the framework your tests use is installed in that interpreter. For pytest, install pytest in the selected environment before choosing it as the runner. PyCharm detects installed runners; if none is selected or available, it uses unittest. See JetBrains’ pytest setup guide.
As an Amazon Associate I earn from qualifying purchases.
Use the framework the project already depends on rather than changing runners just to try a different option. PyCharm documents support for unittest, pytest, nose, tox, Twisted Trial, doctests, and several BDD frameworks, but the integration features vary; BDD framework support is marked as PyCharm Pro-only. The framework support overview is in JetBrains’ testing frameworks documentation.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute2. Set or verify the default runner
- Open Settings (on macOS, Preferences).
- Go to Python → Tools → Integrated Tools.
- Under Testing, select the project’s default test runner, such as pytest or unittest.
This setting is the default for new launches, not necessarily the runner for every test you already ran. An existing run/debug configuration associated with a file and framework can take precedence. If the expected runner is missing, check that it is installed in the project interpreter, then revisit the setting.
#1 Best Overall
3. Run one test from the editor
Open a test file and use the gutter icon beside the test function or method. Select Run and the test name from the menu. You can also right-click the test in the editor and choose the run action from the context menu. PyCharm starts the test and displays its status and output in the Test Runner tab. These launch options and temporary configurations are covered in JetBrains’ Run tests documentation.
If no matching run/debug configuration exists, PyCharm creates a temporary one for the launch. That is convenient for a quick check; to reuse or customize the settings, save the configuration and edit it rather than relying on the temporary run.
Rank #2
4. Run a file, class, or directory
The same approach scales to a larger scope. Use the gutter or editor context menu to run a test file or class, or right-click the relevant test directory in the Project tool window and choose the run action. Select the target deliberately: a single test is faster for a focused check, while a directory run covers the tests grouped there.
For a reusable pytest launch, open Run → Edit Configurations and create or select a pytest configuration. Its target can be a script, module, or custom target, and you can supply additional arguments. This is useful when you repeatedly run a particular subset or need pytest options. The available target and argument fields are described in JetBrains’ pytest run/debug configuration reference.
5. Read the Test Runner results
The Test Runner tab organizes results in a test tree, with status indicators that help you distinguish successful and failed tests. Expand the tree to locate a failure, then open the test from the result. The tab also provides test output and inline timing information, which can help identify where a run failed or which test took longer. JetBrains documents the result view in its Test Runner tab guide.
6. Debug pytest tests when needed
For a failing test that needs closer inspection, use the gutter or context-menu Debug action rather than Run. This launches the test under the debugger so you can step through execution and inspect values.
If pytest-cov interferes with debugging, JetBrains’ targeted workaround is to add --no-cov -s in the pytest configuration’s Additional Arguments. This is a troubleshooting option for that interaction, not a general requirement for pytest. See the pytest configuration reference.
7. Collect test coverage
Coverage is a separate run mode. Select Run with Coverage from a run configuration, the Project tool window, or the editor’s run menu. PyCharm then displays coverage results alongside the test run. Coverage settings control how newly collected data is applied to active suites; consult JetBrains’ running tests with coverage guide and coverage settings reference if you need to change suite handling.
Best Value
8. Optional: add checks or parallel execution
Run tests before committing
PyCharm documents test checks for Git and Mercurial commit workflows. If you want tests to run as part of committing, configure the relevant commit check in the IDE’s commit options. The exact controls depend on the version-control workflow you use; see JetBrains’ Run tests documentation.
Run pytest tests in parallel
For pytest projects, PyCharm documents parallel execution through pytest-xdist and an explicit worker count, using the argument -n <number of CPUs>. Install pytest-xdist in the project interpreter before using it. Parallel runs can consume more system resources, so they are an optional speed-up rather than a default requirement. Details are in the same Run tests guide.
Quick Recap
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.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →




