Skip to content
Advertisement

VSCode Python Test Discovery fails?

VS Code version: version Version: 1.69.2 (Universal))

Extension version (available under the Extensions sidebar): v2021.12.1559732655

OS and version: MacOS 12.3.1

Python version: 3.6.8

Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv

Relevant/affected Python packages and their versions: pytest==7.0.1

problem:

JavaScript

Advertisement

Answer

Since none of the above answers solved my problem, I recently google the information myself and found the root cause. I added the following statement to the conftest.py file

JavaScript

The result obtained is

US-ASCII — utf-8

Checked the documentation to confirm the environment variables that affect sys.stdout.encoding

LC_CTYPE LANG

because the test find script was found to execute successfully in terminal.

JavaScript

In the terminal, look at these two environment variables and add them to the .env file.

LANG=”zh_CN.UTF-8″ LC_CTYPE=”zh_CN.UTF-8″

The problem is solved.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement