Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report