Python in the HTTP protocol interface related libraries have URLLIB,URLLIB2 and Reqeusts library, which Reqeusts library for the most convenient, so I also mainly use the requests library to do the interface test HTTP protocol. Let's start by looking at what environment information is needed:
First, install Python
The Mac comes with Python installed, and that's not much to say.
Second, install the virtual environment:
We can install multiple versions of Python on a single machine, so we can install the virtual environment to keep each version of the environment from interfering with each other:
1, installation Virtualenv:pip install Virtualenv
2. Create a new virtual environment named Venv: Virtualenv venv
3. Enter the new environment: source Venv/bin/activate
4. Exit: Deactivate
Third, install requests library:
>>>PIP Install Requests
This library is used for interface testing of HTTP protocols using Python.
Iv. HTTP Test Tools:
An HTTP request and response service written using Python + Flask, which is primarily used to test HTTP libraries. Follow-up tests are based on this site.
http://httpbin.org/
Five, the local construction Httpbin:
Considering the testing to continue to visit the Httpbin website, request too much worry to be pulled to the blacklist, we build a set of Httpbin service in this blog.
1. Installation: Pip install Gunicorn
2. Installation: Pip install Httpbin
3, start: Gunicorn Httpbin:app
At this point, the environment has been completed, you can start to play ~
Python Interface Automation Test (i)-Environment preparation