跳转到主要内容

用于测试在yaml文件中定义的可执行文件的玩具项目

项目描述

围绕py.test的包装器,用于运行UNIX命令并检查其中的一些行为。

made-with-python master-pipeline license-GPL-2 license-CeCILL-2.1 project-url repository-url

安装和运行

主要要求

  • 类Unix

  • Python 3.6, 3.7或3.8

从PyPA (pip安装)

安装

最新打包版本可以使用pip安装,带有适用于您用例的选项 [1]

pip install test_exe_matrix

运行

test_exe_matrix [arguments...]

使用poetry从源代码

安装

关于poetry的说明:您可以从pip (pip install --user poetry) 安装它 [2] 或遵循 官方网站上的说明

git clone https://framagit.org/feth/test_exe_matrix.git
cd test_exe_matrix
poetry install

运行

poetry run test_exe_matrix [arguments...]

命令行选项

典型用途

[poetry run] test_exe_matrix

概要

usage: test_exe_matrix [-h] [-V] [--collect-only] [-v] [--markers]
                       [-m PYTEST_ARGS]
                       [testsuite [testsuite ...]]

Test command lines listed in yaml files.

positional arguments:
  testsuite       testsuite yaml file -see example
                  test_exe_matrix/matrix.yaml.
                  Argument can be specified multiple times

optional arguments:
  -h, --help      show this help message and exit
  -V, --version   show program's version number and exit
  --collect-only  Only collect tests, without running them.
  -v              Increase verbosity.
  --markers       Lists registered test markers.
  -m PYTEST_ARGS  Only run tests that match selection expression, ie. '-m "not
                  internet"'

test_exe_matrix is mainly a Py.test wrapper

-v 参数添加了非常漂亮的颜色,多亏了 py.test。

测试参数化

将测试套件放在 yaml 文件中,例如 matrix.yaml(已提供),或者多个文件中。每个 yaml 文件都将具有独立的全局配置(标记声明和通用超时)。

最小可行性测试

- exe: /path/to/exe

如果满足默认值,则测试将成功:见下文(可选值)。

可选值

超时

允许运行时间(以秒为单位)。程序将在此延迟后终止。默认为 config/timeout 或 1。

retcode

期望的返回代码。

stdout

期望的标准输出(完全匹配)

stderr

期望的标准错误(完全匹配)

partstdout

期望出现在标准输出中的子串。

partstderr

期望出现在标准错误中的子串。

notinstdout

不期望出现在标准输出中的子串。

notinstderr

不期望出现在标准错误中的子串。

args

程序的参数列表。

name

正在进行的测试的描述。

expect_too_long

布尔值:是否期望程序运行时间超过时间限制。

markers

测试的标记列表。您可以使用标准的 py.test 标记(特别是 'xfail':表示 '预期失败')或自定义标记,这些标记必须在配置部分声明。

示例

提供了一个完整的(希望如此)示例文件,名为“matrix.yaml”。

根据示例,您可以

test_exe_matrix matrix.yaml --collect-only

列出测试,以及

test_exe_matrix matrix.yaml -v -m "not internet and not slow"

取消选择所有需要互联网和缓慢的测试。

screenshot of the above command and output.

开发:构建包

项目使用 poetry。执行

poetry build

并且一个可安装的 wheel 包将出现在 dist/ 目录下。例如,您可以

pip3 install dist/test_exe_matrix-0.0.18-py3-none-any.whl

其他打包方式

Debian/Fedora/Conda 软件包会很好,但我不知道从哪里开始。如果必须放弃 Poetry,那就让它去吧。欢迎提供帮助。

许可

根据您的选择,双重许可(CeCILL 2.1 和 GPL 2)向公众开放,请参阅文件 LICENSE_CeCILL_2.1.txt 和 LICENSE_GPL_2.txt。

这些是兼容的 copyleft 许可证;CeCILL 2.1 至少更适合法国。

其他需求:请与我联系。

感谢

Stéphane Bortzmeyer,他曾经询问是否有一个简单的工具可以测试命令的结果,然后报告了错误/在 framagit/gitlab 上编写了有用的工单以指导开发。

项目详情


下载文件

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

源分布

test_exe_matrix-0.1.5.tar.gz (24.3 kB 查看哈希值)

上传时间

构建分布

test_exe_matrix-0.1.5-py3-none-any.whl (24.2 kB 查看哈希值)

上传时间 Python 3

由以下组织支持