在 python 中使用邮递员集合 V2.1 的库。
项目描述
邮递员2py
postman2py 是一个运行 Postman 集合的Postman库。
最初是从https://github.com/k3rn3l-p4n1c/postpython和https://github.com/matkapi/postpy2分叉的, 添加了一些与 Postman 集合导入和 urlencoded 请求类型相关的更新。
为什么使用 postman2py 而不是 postman codegen?
- 没有硬编码的变量
- 如果您的团队使用邮递员集合进行测试,并且您想通过集成一些计算等来扩展测试。
如何安装?
postman2py 在PyPI上可用 ,您可以使用 pip 安装它:
$ pip install postman2py
如何使用?
进口postman2py
from postman2py.core import PostPython
runner = postman2py('/path/to/collection/postman_collection.json')
# runner.default.<request_name> # if no folders in collection
# runner.<folder_name>.<request_name> # if folders exist in collection
response = runner.default.get_request()
print(response.json())
print(response.status_code)
加载环境变量
在 postman2py 中,您可以从 postman 环境文件中加载环境变量
pp.environments.load('environments/postman_environment.json')
设置环境变量
runner.environments.update({'BASE_URL': 'http://127.0.0.1:5000'})
runner.environments.update({'PASSWORD': 'test', 'EMAIL': 'you@email.com'})
属性错误
如果您拼写错误的函数或文件夹,postman2py 会尝试纠正您的错误,它会建议您最接近的名称。
>>> response = runner.RequestMethods.get_requasts()
Traceback (most recent call last):
File "test.py", line 11, in <module>
response = runner.RequestMethods.get_requasts()
File "/usr/local/lib/python3.5/site-packages/postman2py/core.py", line 73, in **getattr**
'Did you mean %s' % (item, self.name, similar))
AttributeError: get_requasts request does not exist in RequestMethods folder.
Did you mean get_request
您还可以使用help()
方法打印所有可用的请求。
>>> runner.help()
>>> Posible requests:
>>> runner.AuthOthers.hawk_auth()
>>> runner.AuthOthers.basic_auth()
>>> runner.AuthOthers.oauth1_0_verify_signature()
>>> runner.RequestMethods.get_request()
>>> runner.RequestMethods.put_request()
>>> runner.RequestMethods.delete_request()
>>> runner.RequestMethods.post_request()
>>> runner.RequestMethods.patch_request()
or
>>> runner.RequestMethods.help()
>>> runner.RequestMethods.delete_request()
>>> runner.RequestMethods.patch_request()
>>> runner.RequestMethods.get_request()
>>> runner.RequestMethods.put_request()
>>> runner.RequestMethods.post_request()
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
postman2py-0.0.2.tar.gz
(5.2 kB
查看哈希)
内置分布
postman2py-0.0.2-py3-none-any.whl
(17.7 kB
查看哈希)
关
postman2py -0.0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | db0d74db94e88647f889634583c673d1b24ca840ed3391d9bbd23396d33b5b44 |
|
MD5 | 399ea28ca0cb924c2eabd64e78137476 |
|
布莱克2-256 | 6cd5a6d5de25465cf0d09b8a5c10b99b5ac77aea2be099c6209454d44c3a1e8f |
关
postman2py -0.0.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 960d7701f802d3b3a6395bdc103c0ade48684911a4cadea3e6053354c04f6f5c |
|
MD5 | 67c7fef62b6486e2daf99a0c4dede87e |
|
布莱克2-256 | 14710fc3a076fe0f5241a01f20addd3e67b2e954bbd0a587cb485adfd395b057 |