Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The default operation mode of pycharm---- modification script and the solution of not generating HTML test report

Shulou Source: shulou.com Published: 2022-06-03 05:18:29 10月01日 Update

The tool that Python often uses to test and write code is pycharm, but when we run the code, we will find several

Different operation modes, such as run unittest in xxx.py, run xxx.py,run py.test in xxx.py

I. run unittest in mode

This is the default operation mode of pycharm, so many times when you join HTMLTestRunner to generate reports, it will not generate reports for you, because it has already been run by unittest by default.

Let's see how to modify it:

Win:

1. Win can be changed in the settings.

Here, just change Default test runner to py.test.

2. Modify it by editing Run/Debug Configurations

Use the plus sign to add the way in which the steps to be run are run. And specify the path of the step, and then run this step with this setting.

3. Another situation is that files that start with the name test*.py will also be run with unittest by default.

In this case, you just need to remove the test and run it again and it will not run as unittest.

Mac:

On the Mac side, I only find that I can pass the second and third methods above. The first method seems to be unable to find the entrance. Which student can find it?

You can leave a message for discussion.

II. Run xxx.py

To set this mode to run, you need to set it in the edit mode of configurations

Click the plus sign to add python, and then select the footstep path to follow the IDLE window that comes with python.

All right, it's the same effect.

III. Run py.test in

This method is also set in configurations mode.

Click the plus sign, then select python tests---py.test, and then set the footstep path.

There are only three basic methods to run, especially when you don't run in unittest.main (), we often run our code instead of unittest.main () by default, and it's normal when you put your footsteps into IDLE. Just follow the above method to set it up.

Tags: Run mode step method code plus sign time path just need situation mode face select report test generate different entry again again Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Information Apple OPPO Reno Microsoft