# pytest-timeouts
[![Build Status](https://travis-ci.org/Scony/pytest-timeouts.svg?branch=master)](https://travis-ci.org/Scony/pytest-timeouts)
[![codecov](https://codecov.io/gh/Scony/pytest-timeouts/branch/master/graph/badge.svg)](https://codecov.io/gh/Scony/pytest-timeouts)
[![Documentation Status](https://readthedocs.org/projects/pytest-timeouts/badge/?version=latest)](https://pytest-timeouts.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/pytest-timeouts.svg)](https://pypi.org/project/pytest-timeouts/)
![pyversion](https://img.shields.io/pypi/pyversions/pytest-timeouts.svg)
![Supported pytest 3|4](https://img.shields.io/badge/pytest-3|4-blue.svg)
[![Downloads](https://pepy.tech/badge/pytest-timeouts)](https://pepy.tech/project/pytest-timeouts)
[![PyPI - License](https://img.shields.io/pypi/l/pytest-timeouts.svg)](https://github.com/Scony/pytest-timeouts/blob/master/LICENSE)
![GitHub Release Date](https://img.shields.io/github/release-date/Scony/pytest-timeouts.svg)
Linux-only Pytest plugin to control durations of various test case execution phases.
## Documentation
For documentation visit [pytest-timeouts.readthedocs.io](https://pytest-timeouts.readthedocs.io).
## About
This plugin has been designed for specific use cases which are out of the scope of famous `pytest-timeout` plugin.
It uses a `SIGALRM` signal to schedule a timer which breaks the test case.
## Features
* `setup`, `execution` and `teardown` phase timeouts controllable by:
* opts: `--setup-timeout`, `--execution-timeout` and `--teardown-timeout`
* ini: `setup_timeout`, `execution_timeout` and `teardown_timeout`
* mark: `setup_timeout`, `execution_timeout` and `teardown_timeout`
* fixed order of timeout settings: **opts** > **markers** > **ini**, controlled by `--timeouts-order`
* `--timeouts-order` allow change order of override timeout settings, and disable some settings, i.e. `--timeout-order i` disable markers and opts, any combination is allow
* timeout disabled when debugging with PDB
## Installation
### Stable
```bash
pip install pytest-timeouts
```
### Master
```bash
pip install git+https://github.com/Scony/pytest-timeouts.git
```
## Usage
### Command line
```bash
pytest --setup-timeout 2.5 --execution-timeout 2.01 --teardown-timeout 0
```
### `pytest.ini` setting
```ini
[pytest]
setup_timeout = 2.5
execution_timeout = 2.01
teardown_timeout = 0
```
### Mark
```python
import time
import pytest
@pytest.mark.setup_timeout(0.3)
@pytest.mark.execution_timeout(0.5)
@pytest.mark.teardown_timeout(0.4)
def test_timeout():
time.sleep(1)
```
## Contributors
* Pawel Lampe
* Kamil Luczak
Python库 | pytest-timeouts-1.2.tar.gz
版权申诉
65 浏览量
2022-04-13
22:29:57
上传
评论
收藏 5KB GZ 举报
挣扎的蓝藻
- 粉丝: 12w+
- 资源: 15万+
最新资源
- 基于python开发的口红色号识别程序+源码+开发文档+源码解析(毕业设计&课程设计&项目开发)
- TP-LINK TL-WN725N V3 Linux 驱动
- 020ssm-jsp-mysql班级同学录网站.zip(可运行源码+数据库文件+文档)
- 什么是stm32f103rct6,有哪些优缺点?
- 李明哲尚能2.zip
- 019ssm-jsp-mysql奥迪维修保养服务管理系统.zip(可运行源码+数据库文件+)
- AB测试数据-增设中小店铺广告位
- YOLOv8红外场景的车辆-行人-斑马线-交通灯检测+数据集+pyqt界面
- 基于JSP毕业设计-OA办公自动化系统-毕业设计.zip
- 基于JSP毕业设计-MVC设计模式应用之游戏卡在线销售系统(论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈