Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions.
Project description
pytest-yaml-sanmu
pytest-yaml-sanmu is a plugin for pytest
_ that considers YAML files as test case.
In this way, we can use markers, fixtures, variables, and even call Python functions in YAML.
For more information, please click here .
Require
python>=3.12
pytest>=8.2
pyyaml~=6.0
pyyaml-include~=1.3.1
Install
pip install pytest-yaml-sanmu
Config
# pytest.ini
[pytest]
# To execute YAML files starting with "test_"
yaml_run_case = true
Usage
1. Write tests
# test_api.yaml
name: fetch baidu # Each test case has a name
steps: # Each test case has multiple steps
- request: # steps 1: send request
method: get
url: https://www.baidu.com
- response: # steps 2: assert response
status_code: 200
text: "*baidu*"
2. Write Hook
# conftest.py
import requests
import responses_validator
def pytest_yaml_run_step(item):
step = item.current_step
request = step.get('request')
response = step.get('response')
if request:
print(f'url={request["url"]}')
item.resp = requests.request(**request)
if response:
responses_validator.validator(item.resp, **response)
return True
3. Run pytest
(.venv) ~/pytest-yaml-demo>pytest
================== test session starts ==================
platform win32 -- Python 3.12.2, pytest-8.2.2, pluggy-1.5.0
rootdir: ~/pytest-yaml-demo
configfile: pytest.ini
plugins: allure-pytest-2.13.5, yaml-0.3.0.dev3
collected 1 item
test_api.yaml . [100%]
================== 1 passed in 0.22s ==================
FeedBack
WeChat: python_sanmu
Article
- pytest-yaml-sanmu(一):把yaml作为测试文件的pytest插件
- pytest-yaml-sanmu(二):使用hook自定义yaml用例的执行方式
- pytest-yaml-sanmu(三):使用yaml进行API测试和Web测试
- pytest-yaml-sanmu(四):标记和筛选YAML用例
- pytest-yaml-sanmu(五):跳过执行和预期失败
- pytest-yaml-sanmu(六):YAML数据驱动测试
- pytest-yaml-sanmu(七):使用fixture返回值
- pytest-yaml-sanmu(八):定义和使用变量
- pytest-yaml-sanmu(九):注册和调用Python函数
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp313-cp313-win_amd64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 244.2 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
47b0288542e5cf79c22afd110d0587076488f9038e72e1c28030630b23fcbfed
|
|
MD5 |
58f8c1fff2d58270296573ff78a4e049
|
|
BLAKE2b-256 |
b4a8316799ca8221d414d3dcd0858184d7b5ed0af09121fe23284b4422560208
|
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
ff499eb044760fabddd15fb425bd46a8c3564de3771eaa712d8ec0404df6c06c
|
|
MD5 |
1221941fa97cf9818f2efd32a5ed2918
|
|
BLAKE2b-256 |
a85aaf1ae597a27bb1d7cb451b13ee2b15d81728f3c533adb7bd62ada9d73869
|
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a10d40a13ff73a3fea5182490bfa122ae8c594a1a6fa9930952a315842b5f47a
|
|
MD5 |
bb67a2398124c031a61b8acdaa0e1cfc
|
|
BLAKE2b-256 |
4cdb6b00445cf5380a28a2bf7532a44c38a55a8534eeee5c8c7d45d9a411af1c
|
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp313-cp313-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 254.0 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0ea5adb44af654f61fbf998d62db280a65fd2fd9817444f8dc2ca1b7f4576714
|
|
MD5 |
a6463a63707a4532e29397eb5cb52aa5
|
|
BLAKE2b-256 |
475df986ad806f194460d01487964fcae5bf34c87643c10679b7154b09c9270b
|
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl
- Upload date:
- Size: 262.8 kB
- Tags: CPython 3.13, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
89edf582416a69637fdbcc447cd8d32295ddc4abbde55041334ee9620c6c3297
|
|
MD5 |
789bffcc86935920e2b2332b86d6519d
|
|
BLAKE2b-256 |
5a3e1039caf1c2d576747983dc217d035faaa9cde92910054cdb4504257fce46
|
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 248.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
adf81487010bc32bf9a3b54580715d79bc8abff0e53567dfc500723526937157
|
|
MD5 |
3f97ea8313da4107de826a9b30c349d8
|
|
BLAKE2b-256 |
a479b50a4cc921b8fca001daaf1f3b67845fb1025ad1efb427ada2a680192194
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-win_amd64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-win_amd64.whl
-
Subject digest:
adf81487010bc32bf9a3b54580715d79bc8abff0e53567dfc500723526937157
- Sigstore transparency entry: 158661867
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Branch / Tag:
refs/tags/ci_1.1.1_publish
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
88bd784e21dfcd744970c068e6e7502a1584a662a6b62f907988f7c3d0ee3a7a
|
|
MD5 |
796c3f793a139ace2728792b4c1c558f
|
|
BLAKE2b-256 |
6e64dc714e791f5f4ef73f465a5fffffd45ccedca484f09d4451828edc3e138e
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
-
Subject digest:
88bd784e21dfcd744970c068e6e7502a1584a662a6b62f907988f7c3d0ee3a7a
- Sigstore transparency entry: 158661872
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Branch / Tag:
refs/tags/ci_1.1.1_publish
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
65de0e3bd77cd50acedcf93917d6c731360ba473e08114d3dbf3dbf3751f1b85
|
|
MD5 |
7a0b3a73e25d70615796125b3e2f85b2
|
|
BLAKE2b-256 |
fdc4b06e89ceb76bd62be956b6233253b4c0871de2f00d3a0f0fcc15da2d68e1
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
-
Subject digest:
65de0e3bd77cd50acedcf93917d6c731360ba473e08114d3dbf3dbf3751f1b85
- Sigstore transparency entry: 158661869
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Branch / Tag:
refs/tags/ci_1.1.1_publish
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_14_0_arm64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 259.9 kB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
3d17f59e2f6cb42e9fd49778460633df5f852dcb947b23dda3c8fbc6b72da978
|
|
MD5 |
1803399fb13792069b3e4ae075704b01
|
|
BLAKE2b-256 |
09783fc425fbd4e343b09a98235fc12a15c9ce1aa6202711f8a8e7b71d8df051
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_14_0_arm64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_14_0_arm64.whl
-
Subject digest:
3d17f59e2f6cb42e9fd49778460633df5f852dcb947b23dda3c8fbc6b72da978
- Sigstore transparency entry: 158661871
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Branch / Tag:
refs/tags/ci_1.1.1_publish
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_13_0_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_13_0_x86_64.whl
- Upload date:
- Size: 268.9 kB
- Tags: CPython 3.12, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
86c6f4bc3a9e0b6d834df40c20bf67ef59ccdb2de2bd17f3b87c48b1618e5d9f
|
|
MD5 |
35c70b38b518d1fb63103edca760dd59
|
|
BLAKE2b-256 |
55ea77d1efa9650e9d5d58ce4b6b1113adcc816ef7ccb9594eeaed78ef135c5b
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_13_0_x86_64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_13_0_x86_64.whl
-
Subject digest:
86c6f4bc3a9e0b6d834df40c20bf67ef59ccdb2de2bd17f3b87c48b1618e5d9f
- Sigstore transparency entry: 158661870
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Branch / Tag:
refs/tags/ci_1.1.1_publish
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@3260ea03e26b1b9d9159099d4c0dfd11000c6561
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 259.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
49b598b951f839cec21954395081d795034bf8f479fb7bba729d6fba2f73ccfe
|
|
MD5 |
de3447c4a2c9f764bbafbad2a0ec01a6
|
|
BLAKE2b-256 |
923f9311868ba4a42f97cf762888c3c12cd25cea39531558c19b46bcdc8a59f5
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_11_0_arm64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_11_0_arm64.whl
-
Subject digest:
49b598b951f839cec21954395081d795034bf8f479fb7bba729d6fba2f73ccfe
- Sigstore transparency entry: 158973772
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@0088ae80341c32f560ebb3ef82a8b3346270bff1
-
Branch / Tag:
refs/tags/ci_1.1.1_py313
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@0088ae80341c32f560ebb3ef82a8b3346270bff1
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 269.0 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8d419ba6435b1a17e57859a61763b3a47b94c98951bf2b3afe6f8e4b824e361d
|
|
MD5 |
ed810bc64bcaf3c1bfbf9ccb42d6d061
|
|
BLAKE2b-256 |
4040edd9506d4feca83faca06c2b15d01a127e1b6489e9b49f9943d6026aca25
|
Provenance
The following attestation bundles were made for pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl
:
Publisher:
publish-to-pypi.yml
on dongfangtianyu/pytest-yaml-sanmu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_yaml_sanmu-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl
-
Subject digest:
8d419ba6435b1a17e57859a61763b3a47b94c98951bf2b3afe6f8e4b824e361d
- Sigstore transparency entry: 158973780
- Sigstore integration time:
-
Permalink:
dongfangtianyu/pytest-yaml-sanmu@0088ae80341c32f560ebb3ef82a8b3346270bff1
-
Branch / Tag:
refs/tags/ci_1.1.1_py313
- Owner: https://github.com/dongfangtianyu
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@0088ae80341c32f560ebb3ef82a8b3346270bff1
-
Trigger Event:
push
-
Statement type: