In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "the difference between the use of python+unittest in linux and windows environment". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the difference between the use of python+unittest in linux and windows environment.
1. Explain with an example of the contents of the document:
In windows environment, the content of send_email.py file in lib directory is different from that of send_email.py file in lib directory in Linux environment, as shown in the screenshot annotations:
The send_email.py file in Linux environment is written as follows:
Att = MIMEText (open (config.basedir +'/ Report.zip', 'rb'). Read (),' base64', 'utf-8')
The reason is:
When the all_start.py file under the project directory / test/testsuit is executed successfully in 1.windows environment, the Report.zip file will be generated in the current directory.
After the successful execution of the all_start.py file under the project directory / test/testsuit in the 2.linux environment, the Report.zip file (directory: / home/devops/STG_API_unittest) will be generated under the root directory of the project, instead of the Report.zip file under the directory: / home/devops/STG_API_unittest/test/testsuit, so it needs to be modified.
2. The contents of the / test/testsuit/all_start.py file under the project directory are as follows:
In windows environment, the contents of all_start.py file should be noted as shown in the screenshot annotations:
Just need to be in the all_start.py file: import unittest module
In linux environment, the content of all_start.py file is about: suite = unittest.defaultTestLoader.discover (basedir +'/ test/testcase/CHE001_API/APP_vehicle_V1.10', pattern='*.py')
The writing is changed to:
Test_Loader = DiscoveringTestLoader ()
Suite = test_Loader.discover (basedir +'/ test/testcase/CHE001_API/APP_vehicle_V1.10', pattern='*.py')
And add: from discover import DiscoveringTestLoader at the top of the all_start.py file
If the import reports an error, install discover,pip install discover first
At this point, I believe you have a deeper understanding of "the difference between the use of python+unittest in linux and windows environment". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.