# Pytest

Create: `Run | Edit Configurations |` ![Add New Configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) `| Python Tests | pytest`

> **Note:**
> If you use the [pytest-cov](https://pypi.org/project/pytest-cov/) plugin, it may interfere with the debugger. To avoid this, add `--no-cov -s` in the Additional Arguments field of the dialog.

Use this dialog to create a run/debug configuration for [pytests](http://pytest.org).

## Toolbar

The tree view of run/debug configurations has a toolbar that helps you manage configurations available in your project as well as adjust default configurations templates.

| Item | Shortcut | Description |
| --- | --- | --- |
| ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) | `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌥ Insert` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)) | Create a run/debug configuration. |
| ![the Remove button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg) | `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `⌘ ⌦` (Xcode), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (ReSharper), `⌥ ⌦` (ReSharper (macOS)), `Alt+Delete` (QtCreator), `⌘ ⌦` (QtCreator (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS)) |  Delete the selected run/debug configuration. Note that you cannot delete default configurations.  |
|  ![Copy](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.copy.svg)  |  `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Meta+D` (Emacs), `Ctrl+Shift+D` (Sublime Text), `⌘ ⇧ D` (Sublime Text (macOS)), `⌘ D` (Xcode), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (ReSharper), `⌘ D` (ReSharper (macOS)), `Ctrl+D` (QtCreator), `⌘ D` (QtCreator (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Eclipse), `Ctrl+D` (Eclipse (macOS))  |  Create a copy of the selected run/debug configuration. Note that you create copies of default configurations.  |
| ![Save configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.save.svg) |  | The button is displayed only when you select a [temporary configuration](run-debug-configuration.html). Click this button to save a temporary configuration as permanent.  |
|  ![Move into new folder / Create new folder](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.actions.newFolder.svg)  |  |     Move into new folder / Create new folder. You can group run/debug configurations by [placing them into folders](run-debug-configuration.html#config-folders).       To create a folder, select the configurations within a category, click ![Folder](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.nodes.folder.svg), and specify the folder name. If only a category is in focus, an empty folder is created.       Then, to move a configuration into a folder, between the folders or out of a folder, use drag or ![Move Up](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveUp.svg) and ![Move Down](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveDown.svg) buttons.       To remove grouping, select a folder and click ![Remove Configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg).     |
|  ![Sort configurations](https://resources.jetbrains.com.cn/help/img/idea/2026.2/workspace.xml`.    |

## Pytest-specific onfiguration options

| Item | Description |
| --- | --- |
| Python Interpreter | Select one of the pre-configured [Python interpreters](configuring-available-python-interpreters.html).  |
|  Target: script/module/custom  |     Select the target from the drop-down:        * script: a path to a Python file.    * module: a Python module name and a test class instance.    * custom: an arbitrary combination of paths, modules, and test class instances.      Depending on the selected target type, you can specify the following values:        * Path to the test file, for example, `/Users/jetbrains/Car/my_tests/test_car.py`. You can type in the path or click the ![Browse](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.menu-open.svg) button to locate the file in the project structure.    * Name of the module in your project, for example, `my_tests`. You can type in the module name, search the target module by its name, or locate it in the project structure.    * Custom combination of modules, scripts, classes, and methods, for example, `my_tests.test_car.TestCar.test_brake`, where: * `my_tests`: the package name * `test_car`: the module name * `TestCar`: the class instance in `test_car` * `test_brake`: the method in the `TestCar` class    |
| Additional Arguments |    In this text field, specify the additional framework-specific arguments to be passed to the test as-is, for example:       ``` --some-argument=some-value ```      > **Warning:** > This option is not recommended and should only be used by the experts, who want to launch something not supported by CLion.     |
| Keywords | An expression to match on the test names. See examples on [docs.pytest.org](https://docs.pytest.org/en/latest/example/markers.html#using-k-expr-to-select-tests-based-on-their-name).  |
| Environment variables |  Click the browse button, or press `Shift+Enter` (Windows), `⇧ ⏎` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⇧ ⏎` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Ctrl+Enter` (Sublime Text), `⌘ ⏎` (Sublime Text (macOS)), `⇧ ⏎` (Xcode), `Shift+Enter` (Visual Studio), `⇧ ⏎` (Visual Studio (macOS)), `Shift+Enter` (ReSharper), `⇧ ⏎` (ReSharper (macOS)), `Shift+Enter` (QtCreator), `⌘ ⏎` (QtCreator (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⇧ ⏎` (Eclipse (macOS)) to specify the desired set of environment variables in the Environment Variables dialog. To create a new variable, click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg), and type the desired name and value.  |
| Docker container settings     > **Warning:** > This field only appears when a [Docker-based remote interpreter](docker.html) is selected for a project..     > **Note:** > Speaking about the correspondence of settings with some options (`--net`, `--link`, and so on), note that these options come from [Docker command line arguments](https://docs.docker.com/engine/reference/commandline/run/).       Click ![the Browse button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.general.ellipsis.svg) to open the dialog and specify the following settings:                      |
| Options |      * Disable networking: select this checkbox to have the networking disabled. This corresponds to `--net="none"`, which means that inside a container the external network resources are not available.    * Network mode: corresponds to the other values of the option `--net`. * `bridge` is the default value. An IP address will be allocated for container on the bridge’s network and traffic will be routed through this bridge to the container. Containers can communicate via their IP addresses by default. To communicate by name, they must be linked. * `host`: use the host's network stack inside the container. * `container:<name\|id>`: use the network stack of another container, specified via its name or id. For more information, refer to the [Network settings](https://docs.docker.com/engine/reference/run/#network-settings) documentation.    * Links: Use this section to link the container to be created with the other containers. This is applicable to `Network mode = bridge` and corresponds to the `--link` option.    * Publish all ports: Expose all container ports to the host. This corresponds to the option `--publish-all`.    * Port bindings: Specify the list of [port bindings](https://docs.docker.com/engine/reference/run/#expose-incoming-ports). Similar to using the `-p` option with `docker run`.    * Extra hosts: This corresponds to the `--add-host` option. For more information, refer to [Managing /etc/hosts](https://docs.docker.com/engine/reference/run/#managing-etc-hosts).    * Volume bindings: Use this field to specify the bindings between the special folders-volumes and the folders of the computer, where the Docker daemon runs. This corresponds to the `-v` option. For more information, refer to [Managing data in containers](https://docs.docker.com/userguide/dockervolumes/).    * Environment variables: Use this field to specify the list of environment variables and their values. This corresponds to the `-e` option. For more information, refer to [ENV (environment variables)](https://docs.docker.com/engine/reference/run/#env-environment-variables).     Click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveDown.svg) to expand the tables. Click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg), ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg), or ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.edit.svg) to make up the lists.    |

## Additional options

Click Modify options and select the options that you want to add to the dialog.

### Operating System

| Item | Description |
| --- | --- |
|  Allow multiple instances   |    Allow running multiple instances of this run configuration in parallel.                           By default, it is disabled, and when you start this configuration while another instance is still running, CLion suggests stopping the running instance and starting another one. This is helpful when a run configuration consumes a lot of resources and there is no good reason to run multiple instances.     |

### Python

| Item | Description |
| --- | --- |
| Interpreter options | In this field, specify the [command-line options](https://docs.python.org/3/using/cmdline.html#command-line) to be passed to the interpreter. If necessary, click ![Expand the field](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.general.expandComponent.svg), and type the string in the editor.  |
|  Add content roots to PYTHONPATH  | Select this checkbox to add all [content roots](null) of your project to the environment variable PYTHONPATH.  |
| Add source roots to PYTHONPATH |  Select this checkbox to add all [source roots](null) of your project to the environment variable PYTHONPATH.  |

### Debug

| Item | Description |
| --- | --- |
| Debug just my code | When this option is enabled, the debugger focuses only on user-written code and skips stepping into external libraries. |

### Logs

The following options are related to logging the execution of this configuration. For more information, refer to [](null).

| Item | Description |
| --- | --- |
| Specify logs to be shown in the console   |    Specify which log files to display while running the application.                               Click ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) to add a new log. In the Edit Log Files Aliases dialog, configure the following:                                 * Alias: The name of the tab where the log will be displayed.    * Log File Location: Specify the path to the log file or an [Ant pattern](https://ant.apache.org/manual/dirtasks.html). If several files of a rolling log match the pattern, CLion will display the most recent one.    * Show all files coverable by pattern: Show all logs that match the pattern.                              For logs in the table, you can configure the following options:                                * Is Active: Display the specified log file.    * Skip Content: Do not display old log messages from previous runs.    |
| Save console output to file   | Save the console output to the specified location. Type the path manually or click the browse button and point to the desired location in the [dialog that opens](select-path-dialog.html). |
| Show console when a message is printed to stdout   | Activate the console when the application writes to the standard output stream. |
| Show console when a message is printed to stderr   | Activate the console when the application writes to the standard error stream. |

### Before launch

| Item | Description |
| --- | --- |
| Open run/debug tool window when started   |     By default this option is selected and the [Run](run-tool-window.html) or the [Debug](debug-tool-window.html) tool window opens when you start the run/debug configuration.       Otherwise, the tool window is hidden. However, when the configuration is running, you can open the corresponding tool window for it yourself by pressing `Alt+4` (Windows), `⌘ 4` (macOS), `⌘ 4` (IntelliJ IDEA Classic (macOS)), `⌘ 4` (macOS System Shortcuts), `Alt+4` (XWin), `Alt+4` (GNOME), `Alt+4` (KDE), `Alt+4` (Emacs), `Alt+4` (Sublime Text), `⌘ 4` (Sublime Text (macOS)), `⌘ 6` (Xcode), `Alt+4` (Visual Studio), `⌘ 4` (Visual Studio (macOS)), `Alt+4` (ReSharper), `⌘ 4` (ReSharper (macOS)), `Alt+3` (QtCreator), `⌘ 3` (QtCreator (macOS)), `Alt+4` (NetBeans), `Alt+4` (Eclipse), `⌘ 4` (Eclipse (macOS)) or `Alt+5` (Windows), `⌘ 5` (macOS), `⌘ 5` (IntelliJ IDEA Classic (macOS)), `⌘ 5` (macOS System Shortcuts), `Alt+5` (XWin), `Alt+5` (GNOME), `Alt+5` (KDE), `Alt+5` (Emacs), `Alt+5` (Sublime Text), `⌘ 5` (Sublime Text (macOS)), `⌘ 7` (Xcode), `Alt+5` (Visual Studio), `⌘ 5` (Visual Studio (macOS)), `Alt+5` (ReSharper), `⌘ 5` (ReSharper (macOS)), `Alt+5` (QtCreator), `⌘ 5` (QtCreator (macOS)), `Alt+5` (NetBeans), `Alt+5` (Eclipse), `⌘ 5` (Eclipse (macOS)).     |
| Focus run/debug tool window when started   |  Select this option to automatically move focus to the [Run](run-tool-window.html) or the [Debug](debug-tool-window.html) tool window when you start the run/debug configuration.     |
| Show the run/debug configuration settings before start   | Select this option to show the run/debug configuration settings prior to actually starting the run/debug configuration.   |
| Add before launch task   |    Select this option to add one of the following available tasks:        * Run External tool: select to run an external application. In the dialog that opens, select one or multiple applications you want to run. If it is not defined in CLion yet, add its definition. For more information, refer to [External tools](configuring-third-party-tools.html) and [External Tools](settings-tools-external-tools.html).    * Run Another Configuration: select to execute another run/debug configuration and wait until it finishes before starting the current configuration. If you want to run several configurations in parallel, use a [compound run/debug configuration](run-debug-multiple.html#compound-configs) .    * Run File Watchers: select this option to have CLion apply all the currently active [File Watchers](using-file-watchers.html).    * Run Grunt task: select this option to run a Grunt task. In the Grunt task dialog that opens, specify the `Gruntfile.js` where the required task is defined, select the task to execute, and specify the arguments to pass to the Grunt tool. Specify the location of the Node.js runtime, the parameters to pass to it, and the path to the grunt-cli package.    * Run gulp task: select this option to run a Gulp task. In the Gulp task dialog that opens, specify the `Gulpfile.js` where the required task is defined, select the task to execute, and specify the arguments to pass to the Gulp tool. Specify the location of the Node.js runtime, the parameters to pass to it, and the path to the gulp package.    * Run npm script: select this option to execute an npm script. In the NPM Script dialog that opens, specify the [npm run/debug configuration settings](installing-and-removing-external-software-using-node-package-manager.html).    * Compile TypeScript: select to run the built-in TypeScript compiler and thus make sure that all the changes you made to your TypeScript code are reflected in the generated JavaScript files. In the TypeScript Compile Settings dialog that opens, select or clear the Check errors checkbox to configure the behaviour of the compiler in case any errors are detected: * If the Check errors checkbox is selected, the compiler will show all the errors and the run configuration will not start. * If the Check errors checkbox is cleared, the compiler will show all the detected errors but the run configuration still will be launched.    * Generate CoffeeScript Source Maps: select this option to generate the source maps for your [CoffeeScript](coffeescript.html) sources. In the dialog that opens, specify where your CoffeeScript source files are located.     |

## See also

### Procedures

[Run/debug configurations](run-debug-configuration.html)

### Language and Framework-Specific Guidelines

### External Links

[pytest feature overview](http://pytest.org)

