跳转到主要内容

pytest_pyramid - 为pytest测试套件提供测试pyramid应用程序的固定装置

项目描述

https://raw.githubusercontent.com/fizyk/pytest_pyramid/master/logo.png

pytest_pyramid

Latest PyPI version Wheel Status Supported Python Versions License

pytest_pyramid为pytest测试套件提供测试pyramid应用程序的基本固定装置。

默认情况下,pytest_pyramid将创建两个固定装置:pyramid_config,它根据config.ini文件创建配置器,和pyramid_app,它根据pyramid_config返回的配置器创建TestApp。

命令行选项

  • –pc - 基于它pytest_pyramid将创建测试应用的pyramid配置文件

用法

对于最基本的使用,pytest_pyramid提供了pyramid_app和pyramid_config固定装置,可以用于测试您的pyramid应用程序。只需将您的pyramid配置 *.ini 文件传递给 –pc 命令行选项,并将 pytest_app 固定装置包含到您的测试套件中,以便能够对其进行集成测试。

固定装置

pytest_pyramid提供了两个固定装置用于pytest测试

  • pyramid_config - 提供pyramid配置文件中定义的Configurator实例的固定装置

  • pyramid_app - 用于测试的pyramid应用程序 - 一个 webtest.app.TestApp

这两个测试夹具都依赖于命令行中传递的配置文件。

测试夹具工厂

如果您正在开发一个模块,一个旨在扩展其他应用程序功能的包,则不需要创建一个完整的应用程序来测试包中提供的功能。为此,pytest_pyramid为您提供了夹具 pytest_pyramid.factories

有两个工厂

  • pytest_pyramid.factories.pyramid_config 根据设置、config_file参数或通过–pc命令行选项提供的配置文件提供配置对象。

  • pytest_pyramid.factories.pyramid_app 基于传递给它的夹具名称返回的Configurator类实例创建一个 webtest.app.TestApp。它还接受在 pyramid_app 之前应加载的附加夹具。以下是一个带有 postgresql 的示例。

from pytest_postgresql.plugin import postgresql
from pytest_pyramid import factories

app_config = factories.pyramid_config(config_path="development.ini")
app_with_postgres = factories.pyramid_app("app_config", "postgresql")

def test_pyramid_app(app_with_postgres):
    res = app_with_postgres.get('/', status=404)
    assert res.status_code == 404

待办事项

  1. 提供 pyramid_proc 夹具,该夹具将使用 summon_process 启动 pyramid 应用程序进程

测试

要运行测试,请运行此命令

pytest –pc tests/pyramid.test.ini

发布

首先安装 pipenv 和 –dev 依赖项,然后运行

pipenv run tbump [NEW_VERSION]

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

pytest_pyramid-1.0.3.tar.gz (7.9 kB 查看哈希)

上传时间

构建分布

pytest_pyramid-1.0.3-py3-none-any.whl (6.9 kB 查看哈希)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页