为py.test提供的Git仓库 fixture
项目描述
创建一个空的Git仓库用于测试,并在拆卸后自行清理。
安装
使用您喜欢的包安装程序进行安装
pip install pytest-git
# or
easy_install pytest-git
在您的测试或conftest.py中明确启用该fixture(当使用setuptools入口点时不需要)
pytest_plugins = ['pytest_git']
用法
此插件是围绕优秀的GitPython库的薄包装(见 http://gitpython.readthedocs.org/en/stable/)。以下是一个简单的测试用例,展示了其工作情况
def test_git_repo(git_repo):
# The fixture derives from `workspace` in `pytest-shutil`, so they contain
# a handle to the path.py path object (see https://pathpy.readthedocs.io/)
path = git_repo.workspace
file = path / 'hello.txt'
file.write_text('hello world!')
# We can run commands relative to the working directory
git_repo.run('git add hello.txt')
# It's better to use the GitPython api directly - the 'api' attribute is
# a handle to the repository object.
git_repo.api.index.commit("Initial commit")
# The fixture has a URI property you can use in downstream systems
assert git_repo.uri.startswith('file://')
变更日志
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 fixture及其测试成为可选的,如所有其他fixture一样
pytest-server-fixtures:撤销对pymongo弃用警告的修复,因为这会破坏与pymongo 3.6.0的兼容性
pytest-server-fixtures:在httpd中移除对RHEL5的支持
1.4.1 (2019-01-18)
pytest-server-fixtures:在ENV中指定的服务器fixture二进制路径现在仅影响服务器类“thread”
1.4.0 (2019-01-15)
在Simple HTTP Server fixture中修复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)
修复当teardown为None时的工作区删除
修复pytest-listener中根记录器的压扁
添加S3 Minio fixture(感谢Gavin Bisesi)
添加Postgres fixture(感谢Gavin Bisesi)
使用requests进行服务器fixture 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中传递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测试设置
处理path.py的旧版本
修复了#40问题,其中chdir测试破坏了pytest-profiling
1.2.5 (2016-12-09)
服务器运行器主机和端口生成的改进,现在支持随机本地IP
修复了RethinkDB测试设置中的错误
1.2.4 (2016-11-14)
修复了pymongo额外依赖项的错误
修复了pytest-virtualenv在Windows上的兼容性问题(感谢Jean-Christophe Fillion-Robin的PR)
修复了pytest-shutil.cmdline.get_real_python_executable的符号链接处理
1.2.3 (2016-11-7)
提高了Mongo测试设置启动检查的容错性
1.2.2 (2016-10-27)
大多数模块支持Python 3兼容性
修复了过时的Path.py导入(感谢Bryan Moscon)
修复了pytest-profiling中的过时multicall(感谢Paul van der Linden的PR)
添加了devpi-server测试设置,为每个测试函数创建一个索引
添加了缺失的许可证文件
拆分了httpd服务器测试设置,以便子类更容易覆盖加载的模块
将“preserve_sys_path”参数添加到TestServer基类中,该参数将当前的python sys.path导出到子进程中。
更新了httpd、redis和jenkins的运行参数和路径,以符合当前的Ubuntu规范
在拆卸工作区时忽略错误,以避免shutil.rmtree实现中的竞态条件
1.2.1 (2016-3-1)
修复了pytest-verbose-parametrize以兼容最新的py.test版本
1.2.0 (2016-2-19)
新插件:git仓库测试设置
1.1.1 (2016-2-16)
pytest-profiling改进:在.prof文件中转义非法字符(感谢Aarni Koskela的PR)
1.1.0 (2016-2-15)
新插件:devpi服务器测试设置
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)
初始公开发布
项目详情
下载文件
为您的平台下载文件。如果您不确定选择哪个,请了解更多关于安装包的信息。