跳转到主要内容

pytest-play 对SQL表达式和断言的支持

项目描述

play sql

https://img.shields.io/pypi/v/play_sql.svg https://travis-ci.org/davidemoro/play_sql.svg?branch=develop Documentation Status https://codecov.io/gh/davidemoro/play_sql/branch/develop/graph/badge.svg

pytest-play 对SQL表达式和断言的支持

更多信息及示例请见

功能

此项目定义了一个新的 pytest-play 命令

- type: sql
  provider: play_sql
  database_url: postgresql://$db_user:$db_pwd@$db_host/$db_name
  query: SELECT id, title FROM invoices
  variable: invoice_id
  variable_expression: results.first()[0]
  assertion: invoice_id == $invoice_id

其中

  • database_url 遵循以下格式描述 https://docs.sqlalchemy.org.cn/en/latest/core/engines.html#database-urls

  • variable_expression 是一个Python表达式
    • results.fetchone() 返回一个数组,其元素与下一行的列相匹配,并且可以多次调用,直到没有更多行(例如:第一次调用 (1, 'first',),第二次调用 (2, 'second')

    • results.first() 返回一个数组,其元素与第一行的列相匹配,并且只能调用一次

    • results.fetchall() 返回一个元组数组,其元素与所选列相匹配(例如:[(1, 'first'), (2, 'second'), (3, 'third')]

Twitter

pytest-play 推文发生在这里

致谢

本软件包是用Cookiecuttercookiecutter-play-plugin(基于audreyr/cookiecutter-pypackage项目模板)创建的。

变更

0.0.3 (2019-01-25)

  • 支持新的pytest-play >= 2.0基于YAML的语法(不再支持json)

0.0.2 (2018-01-22)

  • 不再依赖于play_python(已弃用)

0.0.1 (2018-01-11)

  • 首次发布

项目详情


下载文件

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

源分布

play_sql-0.0.3.tar.gz (17.7 kB 查看哈希值)

上传时间 源代码

构建分布

play_sql-0.0.3-py2.py3-none-any.whl (7.8 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持