1
2
3
4
5
6
7
8
|
/ -
| - pytest.ini # pytest 的配置文件
| - tests
|
| - conftest.py # 全局通用的配置和功能
| - fun_module # 某个模块的测试
| - test_a.py # 该模块下的测试
| - conftest.py # 该模块下通用的配置和功能
|
path/pytest.ini
path/setup.cfg # must also contain [pytest] section to match
path/tox.ini # must also contain [pytest] section to match
pytest.ini
... # all the way down to the root
|
[pytest]
1. 指定测试目录
testpaths = tests
1. 指定测试用例文件的命名格式
python_files = test_*.py
1. 指定 conftest 文件的路径
pytest_plugins = tests
|
def pytest_configure():
pass
|
# pytest . -s
|
@pytest.fixture()
def remote_api():
return 'success'
def test_remote_api(remote_api):
assert remote_api == 'success'
|
import pytest
@pytest.fixture()
def before():
pass
@pytest.mark.usefixtures("before")
def test_1():
pass
|
@pytest.fixture(scope='function')
def func_scope():
pass
@pytest.fixture(scope='module')
def mod_scope():
pass
@pytest.fixture(scope='session')
def sess_scope():
pass
@pytest.fixture(scope='class')
def class_scope():
pass
|
import pytest
A = pytest.mark.A
@A
def test_A():
assert True
|
@pytest.mark.parametrize('name',
['12345',
'abcdef',
'0a1b2c3'])
def test_name_length(passwd):
assert len(passwd) == 6
|
# pytest --cov=myproj tests/
|
import os
class UnixFS:
@staticmethod
def rm(filename):
os.remove(filename)
def test_unix_fs(mocker):
mocker.patch('os.remove')
UnixFS.rm('file')
os.remove.assert_called_once_with('file')
|
# pytest --html=report.html
|
相关推荐
作者:尚卓燃( https://github.com/PsiACE ),Databend 研发工程师,Apache OpenDAL (Incubating) PPMC。 前言 Databend 是一款完全面向云对象存储的新一代云原生数据仓库,专为弹性和高效设计,为您的大规模分析需求保驾护航。Databend 同时是一款符合 Apache-2.0 协议的开源软件,除了访问云服务( https://a
- Argo CD 能解决什么问题 1.1 从 GitOps 说起
Kubernetes 是当前容器编排和管理的主流平台。在更注重稳定性的 1.6 之后,Kubernetes 1.7 带来了五十多个新功能,更侧重于联合、可扩展性、安全性以及部署、扩展和管理容器化应用的其他方式。 以下介绍一些使 Kubernetes 1.7 更稳定和更受欢迎的新功能。 Kubernetes 1.7 的主要功能 API 聚合:与 Kubernetes 1.6 相比,此功能的主要优点是
Zabbix Server 安装 Zabbix Agent 安装 Zabbix agent这里使用docker安装,如果不想安装zabbix_agent也可以的,因为es的数据是通过HTTP的方式获取,可以不安装Zabbix agent docker run -- nam
测试小姐姐正在对云原生的电商应用进行压测,但是如何对压测结果进行持续的观测呢?这一直是比较头痛的事情,本文将介绍如何利用 DeepFlow 的全景拓扑帮助小姐姐快速找到瓶颈点。DeepFlow 全景拓扑无需业务修改代码、配置或者重启服务,利用 BPF/eBPF 技术通过对业务零侵扰的方式构建而来,这是一种很便捷且低成本的方式来观测全链路压测的结果。 背景介绍 DeepFlow 在线的 Sandbo
回到顶部