为py.test提供DevPI服务器固定装置
项目描述
为py.test提供DevPi服务器固定装置。默认情况下,服务器是会话范围的,并在子进程中运行在临时目录中以清理。
服务器启动后,它将创建一个用户和一个密码,并为该用户创建一个索引。然后激活该索引,并提供一个到devpi-client API的句柄,以便您可以在测试中操作服务器。
安装
使用您最喜欢的包管理器进行安装
pip install pytest-devpi-server
# or..
easy_install pytest-devpi-server
在您的测试或conftest.py中显式启用设备(使用setuptools入口点时不需要)
pytest_plugins = ['pytest_devpi_server']
示例
以下是一个简单的测试用例,展示了主要功能
def test_devpi_server(devpi_server):
# This is the client API for the server that's bound directly to the 'devpi' command-line tool.
# Here we list the available indexes
print(devpi_server.api('use', '-l'))
# Create and use another index
devpi_server.api('index', '-c', 'myindex')
devpi_server.api('index', 'use', 'myindex')
# Upload a package
import os
os.chdir('/path/to/my/setup/dot/py')
devpi_server.api('upload')
# Get some json data
import json
res = devpi_server.api('getjson', '/user/myindex')
assert json.loads(res)['result']['projects'] == ['my-package-name']
DevpiServer类
使用默认的devpi_server py.test设备对于许多用例来说已经足够好了,但您可能希望对服务器配置有更细粒度的控制。
为此,您可以直接使用底层服务器类 - 这是pytest-server-fixture框架的一个实现,因此它充当上下文管理器
import json
from pytest_devpi_server import DevpiServer
def test_custom_server():
with DevPiServer(
# You can specify you own initial user and index
user='bob',
password='secret',
index='myindex',
# You can provide a zip file that contains the initial server database,
# this is useful to pre-load any required packages for a test run
data='/path/to/data.zip'
) as server:
assert not server.dead
res = server.api('getjson', '/bob/myindex')
assert 'pre-loaded-package' in json.loads(res)['result']['projects']
# Server should now be dead
assert server.dead
变更日志
1.7.0
所有:支持pytest >= 4.0.0
所有:支持Python 3.7
pytest-server-fixtures:如果您的机器上未定义主机,则默认为localhost
pytest-server-fixture:由于上游API更改,固定rethinkdb < 2.4.0
pytest-verbose-parametrize:添加对改进的标记基础设施的支持
pytest-verbose-parametrize:修复集成测试以支持pytest >= 4.1.0
pytest-virtualenv:添加virtualenv作为安装要求。修复#122
pytest-webdriver:使用getfixturevalue修复RemovedInPytest4Warning
circleci:通过跳过对没有推送访问权限的开发者的coverall提交来修复检查
wheels:生成可同时安装在python 2.x和3.x上的通用wheels
dist:移除构建和分发*.egg文件的支持
VagrantFile:安装python 3.7并默认初始化python 3.7
修复使用“logger.warning()”函数的DeprecationWarning警告
1.6.2 (2019-02-21)
pytest-server-fixtures:如果调用kill(),则抑制堆栈跟踪
pytest-server-fixtures:修复TestServerV2中的随机端口逻辑
1.6.1 (2019-02-12)
pytest-server-fixtures:修复在服务器未启动时尝试访问主机名的异常
1.6.0 (2019-02-12)
pytest-server-fixtures:添加先前删除的TestServerV2.kill()函数
pytest-profiling:在集成测试中固定more-itertools==5.0.0,因为这是一个仅PY3版本
1.5.1 (2019-01-24)
pytest-verbose-parametrize:修复使用@pytest.mark.parametrize时的Unicode参数
1.5.0 (2019-01-23)
pytest-server-fixtures:使postgres设备及其测试可选,如所有其他设备
pytest-server-fixtures:撤销对pymongo弃用警告的修复,因为这会破坏与pymongo 3.6.0的兼容性
pytest-server-fixtures:在httpd中删除RHEL5支持
1.4.1 (2019-01-18)
pytest-server-fixtures:现在只影响服务器类‘thread’的ENV中指定的服务器设备二进制路径
1.4.0 (2019-01-15)
修复Simple HTTP Server设备中的python 3兼容性问题
修复pytest-profiling中的损坏测试
固定pytest<4.0.0,直到所有弃用警告都修复。
pytest-webdriver:用无头Google Chrome替换弃用的phantomjs
将Vagrantfile添加到项目中以使测试环境可移植。
将.editorconfig文件添加到项目中。
pytest-server-fixtures:添加带有Docker和Kubernetes支持的TestServerV2。
pytest-server-fixtures:修复MinioServer使用后未清理的问题。
pytest-server-fixtures:修复调用pymongo时的弃用警告
pytest-server-fixtures:在MongoTestServer拆卸时关闭pymongo客户端
pytest-server-fixtures:将Mongo、Redis和RethinkDB升级到TestServerV2。
coveralls:修复损坏的coveralls
1.3.1 (2018-06-28)
使用pymongo list_database_names()代替已弃用的database_names(),添加pymongo>=3.6.0依赖项
1.3.0 (2017-11-17)
修复在拆卸为None时的工作空间删除问题
修复pytest-listener中根记录器的压缩问题
添加S3 Minio设备(多谢Gavin Bisesi)
添加Postgres设备(多谢Gavin Bisesi)
使用requests对服务器设备的HTTP GET进行设置,因为它正确处理重定向和代理
1.2.12 (2017-8-1)
修复缓存临时主机名的回归,一些客户端依赖于此。现在这是可选的。
1.2.11 (2017-7-21)
修复OSX绑定到非法本地IP范围的问题(感谢Gavin Bisesi)
为pytest-profiling设置和Py3k修复(感谢xoviat)
我们不再尝试在预留本地IP主机时绑定端口5000,因为有人可能已经将其绑定到0.0.0.0
修复了当本地venv未激活时使用gprof2dot的问题
1.2.10 (2017-2-23)
处理pytest-webdriver中的自定义Pytest测试项
1.2.9 (2017-2-23)
将用户名添加到mongo服务器 fixture tempdir 路径中,以防止在共享多用户文件系统上的冲突
1.2.8 (2017-2-21)
在shutil.run.run_as_main中返回函数结果
1.2.7 (2017-2-20)
对较旧的path.py版本进行更多处理
允许pytest-virtualenv中的虚拟环境参数传递
1.2.6 (2017-2-16 )
更新devpi服务器设置以适应devpi-server >= 2.0
随机端口选择改进
HTTPD服务器默认绑定到0.0.0.0以帮助Selenium-style测试
更新mongodb服务器参数以适应mongodb >= 3.2
修正mongodb fixture配置和改进启动逻辑
添加模块范围的mongodb fixture
处理较旧的path.py版本
修复了#40问题,其中chdir断言破坏了pytest-profiling
1.2.5 (2016-12-09)
改进服务器运行器主机和端口生成,现在支持随机本地IP
修正RethinkDB fixture配置的bug
1.2.4 (2016-11-14)
修正pymongo额外依赖的bug
为pytest-virtualenv修复Windows兼容性(感谢Jean-Christophe Fillion-Robin的PR)
修复pytest-shutil.cmdline.get_real_python_executable的符号链接处理
1.2.3 (2016-11-7)
提高Mongo fixture启动检查的容错性
1.2.2 (2016-10-27)
大多数模块的Python 3兼容性
修复了已弃用的Path.py导入(感谢Bryan Moscon)
修复了pytest-profiling中已弃用的multicall(感谢Paul van der Linden的PR)
添加devpi-server fixture以创建每个测试函数的索引
添加缺少的许可文件
将httpd服务器 fixture 配置拆分,以便子类可以更容易地覆盖加载的模块
向TestServer基类添加了“preserve_sys_path”参数,该参数将当前的python sys.path导出到子进程中。
更新httpd、redis和jenkins的运行时参数和路径到当前的Ubuntu规范
在拆除工作区时忽略错误,以避免shutil.rmtree实现中的竞争条件
1.2.1 (2016-3-1)
为最新的py.test修复了pytest-verbose-parametrize
1.2.0 (2016-2-19)
新插件:git仓库fixture
1.1.1 (2016-2-16)
pytest-profiling改进:在.prof文件中转义非法字符(感谢Aarni Koskela的PR)
1.1.0 (2016-2-15)
新插件:devpi服务器fixture
pytest-profiling改进:过长的.prof文件保存为测试名的短哈希(感谢Vladimir Lagunov的PR)
出于安全原因,将workspace.run()的默认行为更改为不使用子shell
修正了virtualenv.run()方法以处理与父方法workspace.run()相同的参数
从virtualenv参数中移除了已弃用的“–distribute”
1.0.1 (2015-12-23)
打包修复
1.0.0 (2015-12-21)
初始公开发布
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
构建分布
pytest-devpi-server-1.7.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1e1a4f4783f6833e49ae72956e68694b26de85e094d39c9cc6e5900774ecf2b9 |
|
MD5 | a30a8efaf8124253d50e5b903efd2041 |
|
BLAKE2b-256 | 443e8ba405dc72895f059270f0e357126bdf897d38d5b017b6318caca0443476 |
pytest_devpi_server-1.7.0-py3.6.egg 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d5e06acdd89966417d781d93cd08a2f1c21265bc06d5e4c1dd9309cdd0af988f |
|
MD5 | f5643047dd344862828d1453be7e4e3f |
|
BLAKE2b-256 | e23100c358451f7ae695beb6069329c24aebe9e35ce2ff39760b6bdcbba53bd0 |
pytest_devpi_server-1.7.0-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a8f37e448d0a8c11c10f51b48a2bae4007431786223c39c3e22343e41f3aa8ee |
|
MD5 | 42ddd6ffb5ba6e151e507974ef35eedc |
|
BLAKE2b-256 | 88594e392f3f2e80d02e00dc3acf4ec24f575f8da416c3d494fa1a2329f7b549 |
pytest_devpi_server-1.7.0-py2.7.egg 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c54e2ad77f9e2031d0284038b2bd1044debfcd1965be81c3d990df39e80503a3 |
|
MD5 | baefa3458de415c8593743e956dd35c3 |
|
BLAKE2b-256 | 97815165b85ba8a2dbda819d7f8aa8bb490663d21e97ad54cce4e64ef745c68e |