Solve: The problem of Run 'python tests for XXX.py' appears when pycharm runs the program

The new version of pycharm2022, when debugging the program, cannot enter __main__, and finally found that the debug mode is pytest. The main reason is that there is a function named test.

1. Problems

When right-clicking to run the code, it is inconsistent with normal operation, and only executes a single function test.

The following screen appears in the right-click menu: " Debug 'Python test for' "


2. Solution 1

Go to the File->Settings->Tools->Python integrated Tools interface, and set Autodetect(pytest) to Unittests to solve this problem.


3. Solution 2

You can directly modify the function name without starting with test. For example, the author here can solve this problem by changing the function name to little_test.

Because there is a test function in the example of the book I read.

 

 

Guess you like

Origin blog.csdn.net/qimo601/article/details/125206840