You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/python/debugging.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Area: python
4
4
TOCTitle: Debugging
5
5
ContentId: 3d9e6bcf-eae8-4c94-b857-89225b5c4ab5
6
6
PageTitle: Debugging Python with Visual Studio Code
7
-
DateApproved: 02/12/2018
7
+
DateApproved: 03/14/2018
8
8
MetaDescription: Debugging Python with Visual Studio Code
9
9
MetaSocialImage: images/tutorial/social.png
10
10
---
@@ -115,7 +115,7 @@ Sets optional environment variables for the debugger process beyond system envir
115
115
116
116
### `envFile`
117
117
118
-
Optional path to a file that contains environment variable definitions.
118
+
Optional path to a file that contains environment variable definitions. See [Configuring Python environments - environment variable definitions file](environments.md#environment-variable-definitions-file).
Copy file name to clipboardExpand all lines: docs/python/environments.md
+43-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Area: python
4
4
TOCTitle: Environments
5
5
ContentId: 8fe4ca8b-fc70-4216-86c7-2c11b6c14cc6
6
6
PageTitle: Configuring Python Environments in Visual Studio Code
7
-
DateApproved: 02/14/2018
7
+
DateApproved: 03/14/2018
8
8
MetaDescription: Configuring Python Environments in Visual Studio Code
9
9
MetaSocialImage: images/tutorial/social.png
10
10
---
@@ -22,6 +22,8 @@ You can also [manually specify an interpreter](#manually-specifying-an-interpret
22
22
23
23
> **Tip:** If you create a new conda environment while VS Code is running, use the **Reload Window** command to refresh the environment list.
24
24
25
+
The extension also loads an [environment variable definitions file](#environment-variable-definitions-file) identified by the `python.envFile` setting. The default value of this setting is `${workspaceFolder}/.env`.
26
+
25
27
## Choosing an environment
26
28
27
29
By default, the Python extension relies on the first Python interpreter it finds in the path, but it's easy to switch between environments.
@@ -125,6 +127,46 @@ To use a Python interpreter that's installed in a virtual environment:
125
127
2. Configure the same `python.pythonPath` variable in `launch.json`.
126
128
3. Ensure that the the libraries and modules you plan on using for linting are installed within the virtual environment.
127
129
130
+
## Environment variable definitions file
131
+
132
+
An environment variable definitions file is a simple text file containing key-value pairs in the form of `environment_variable=value`, with `#` used to mark comments. Multi-line values are not supported.
133
+
134
+
By default, the Python extension loads a file named `.env` in the current workspace folder, as identified by the default value of the `python.envFile` setting (see [General settings](settings-reference.md#general-settings). You can change the `python.envFile` setting at any time to use a different definitions file.
135
+
136
+
A debug configuration also contains an `envFile` property that also defaults to the `.env` file in the current workspace. (See [Debugging - standard configuration and options](debugging.md#standard-configuration-and-options). This property allows you to easily set variables for debugging purposes that replace those used in the default `.env` file.
137
+
138
+
For example, when developing a web application you might want to easily switch between development and production servers. Instead of coding the different URLs and other settings into your application directly, you could use separate definitions files for each. For example:
You can then set the `python.envFile` setting to `${workspaceFolder}/prod.env`, then set the `envFile` property in the debug configuration to `${workspaceFolder}/dev.env`.
169
+
128
170
## Python interpreter for debugging
129
171
130
172
By default, the debugger uses the same `python.pythonPath` setting as for other features of VS Code. Specifically, the value for `pythonPath` in the debugger settings simply refers to the main interpreter setting as follows:
Copy file name to clipboardExpand all lines: docs/python/settings-reference.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Area: python
4
4
TOCTitle: Settings Reference
5
5
ContentId: d256dc5c-95e9-4c02-a82f-947bf34a3517
6
6
PageTitle: Settings Reference for Python
7
-
DateApproved: 12/12/2017
7
+
DateApproved: 03/14/2018
8
8
MetaDescription: Settings Reference for the Python extension in Visual Studio Code
9
9
MetaSocialImage: images/tutorial/social.png
10
10
---
@@ -20,7 +20,7 @@ Refer to [User and workspace settings](/docs/getstarted/settings.md) to find our
20
20
| --- | --- | --- |
21
21
| python.pythonPath |`"python"`| Path to the python interpreter. |
22
22
| python.venvPath |`""`| Path to folder with a list of Virtual Environments, such as `~/.pyenv`, `~/Envs`, `~/.virtualenvs`. |
23
-
| python.envFile |`"${workspaceFolder}/.env"`| Absolute path to a file containing environment variable definitions. |
23
+
| python.envFile |`"${workspaceFolder}/.env"`| Absolute path to a file containing environment variable definitions. See [Configuring Python environments - environment variable definitions file](environments.md#environment-variable-definitions-file). |
24
24
| python.terminal.launchArgs |`[]`| Launch arguments given the Python interpreter when running a file. |
25
25
| python.terminal.executeInFileDir |`false`| Indicates whether to run a file in the file's directory instead of the current folder. |
26
26
| python.terminal.activateEnvironments |`true`| Indicates whether a selected virtual or conda environments is activated when using the **Python: Create Terminal** command or any other operation involving the terminal, such as the **Send Python File to Terminal** menu command. If `false`, skips activating virtual and conda environments before running the commands. |
@@ -162,7 +162,7 @@ Workspace symbols are symbols in C source code generated by the ctags tool (desc
162
162
| --- | --- | --- | --- |
163
163
| pyTestEnabled |`false`| Specifies whether pytest is enabled for unit testing. |[Unit testing](/docs/python/unit-testing.md)|
164
164
| pyTestPath |`"py.test"`| Path to pytest. Use a full path if pytest is located outside the current environment. |[Unit testing](/docs/python/unit-testing.md)|
165
-
| pyTestArgs |`[]`| Arguments to pass to PyTest, with each argument specified as an item in the array. |[Unit testing](/docs/python/unit-testing.md)|
165
+
| pyTestArgs |`[]`| Arguments to pass to PyTest, with each argument specified as an item in the array. When debugging unit tests with pytest-cov installed, include `--no-cov` in these arguments. |[Unit testing](/docs/python/unit-testing.md)|
Copy file name to clipboardExpand all lines: docs/python/unit-testing.md
+4-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Area: python
4
4
TOCTitle: Unit Testing
5
5
ContentId: 9480bef3-4dfc-4671-a454-b9252567bc60
6
6
PageTitle: Unit Testing Python in Visual Studio Code
7
-
DateApproved: 11/10/2017
7
+
DateApproved: 03/14/2018
8
8
MetaDescription: Unit Testing Python in Visual Studio Code
9
9
MetaSocialImage: images/tutorial/social.png
10
10
---
@@ -62,6 +62,9 @@ See [unittest command-line interface](https://docs.python.org/3/library/unittest
62
62
63
63
You can also configure pytest using a `pytest.ini` file as described on [PyTest Configuration](https://docs.pytest.org/en/latest/customize.html).
64
64
65
+
> **Note**
66
+
> If you have the pytest-cov coverage module installed, VS Code doesn't stop at breakpoints while debugging because pytest-cov is using the same technique to access the code being run. To prevent this behavior, include `--no-cov` in `pyTestArgs` when debugging tests. (For more information, see [Debuggers and PyCharm](http://pytest-cov.readthedocs.io/en/latest/debuggers.html) in the pytest-cov documentation.)
0 commit comments