Alibabacloud.com offers a wide variety of articles about python penetration testing, easily find your python penetration testing information here online.
Source: http://andylin02.iteye.com/blog/841604Conclusion: Python's global variables: int string, list, dic (map) can modify its value if there is global. Regardless of whether this global exists in the IF, or whether the if can be executed.However, if there is nopython code
If BGlobal:
Global G_strval;
int string will be an error. The list dic (map) is OK.Python code
#!/usr/bin/dev python
Import Sys
Import OS
G_nva
defAverage (values):"""Compute Average Value>>> Print (average ([+]))20.0>>>the above test syntax >>> needs a blank space, otherwise the test indentation errorafter the test, if the document also needs to write other comments, end with >>>, otherwise this commentwill also be considered as the output of the above test, which is obviously not the output we want.:p Aram Values:: return: """ return sum(values)/ Len(values)# import Doctest# doctest.testmod ()"""directly import the above module
execute a scriptif __name__=="__main__": #do not construct test set, direct test #Unittest.main () #Constructing test SetsSuite=UnitTest. TestSuite () suite.addtest (Test_case ("test_balabala1")) Suite.addtest (Test_case ("TEST_BALABALA2")) #Perform tests " "Texttestrunner is used to execute test cases, you can make testcase, or the results of testsuite tests are saved in TestResult, including executed, passed, and failed use case information" "Runner=UnitTest. Texttestrunner ()
Why do I need a mock
Suppose the system now has two models A and B, where a relies on B (for example, A,b is a function, a function body calls B functions), but B is not completed, or is not in control at this time, and then need to test the function of a, you need to use mock object, simulate a fake Fake_b module , although the Fake_b module is fake, we can customize it by customizing its behavior so that he can look like the function of the "B" module and make a dependent fake_b to test the f
The first time to use Python Django to do page automation, encountered some problems. Now do the recording.The desired effect:In the test interface, click the button to submit the test data and execute testcase. Then open the corresponding browser to execute.The actual problem encountered:Turning on the Django service opens the browser.The query problem is caused by driver= webdriver. Chormen () is executed at initialization. So the browser always ope
There are many types of interfaces, but we often meet the two kinds of get and post that we often use. What is the difference between the two? Personal understanding is mainly expressed in terms of safety.Python code post arbitrary HTTP data and the method of using cookies, the need for friends can refer to.1), when not using cookies, it is very simple to send an HTTP post:Import URLLIB2, Urllib data = {' name ': ' www ', ' password ': ' 123456 '}f = urllib2.urlopen ( url = ' Http://w
greatest common divisor $ defshow_factor (num): -Count = num//2#except 2 - whileCount > 1: the ifNum% Count = =0: - Print('%d The largest approximate number is%d'%(num, count))Wuyi Break theCount-= 1 - Else: Wu Print('%d is the prime number!! '% num)#Execution is all done and executed. - Aboutnum = Int (33) $ Print(Show_factor (num)) - #try...else ... - Try: -int'ABC') A exceptvalueerror as Reason: + Print('something went wrong.'+str (reaso
Manuals and http://www.runoob.com/redis/redis-install.html, as well as start-up and testingPython installation of the Redis modulePIP3 Install RedisPython Code Preliminary:Redis-py provides two classes of Redis and Strictredis for implementing Redis commands, Strictredis is used to implement most of the official commands, and using official syntax and commands, Redis is a subclass of Strictredis, For backwards compatibility with older versions of Redis-pyImport = Redis. Redis (host="localhost"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.