allure-subtests is a Python library that can generate subtest results in an Allure report.
Project description
allure-subtests
Introduction
Allure-subtests is a Python library that can generate subtest results in an Allure report.
Usage
I run below code under:
- Python3.12
from loguru import logger
import allure
class TestSubTest:
def test_demo(self, allure_subtests):
for i in range(3):
with allure_subtests.test(subtest_name=f"custom message:{i=}"):
allure.dynamic.parent_suite('changed parent suite')
logger.info(f'test {i=}')
assert i % 2 != 0
if i == 2:
raise ValueError(f'custom error {i=}')
Why do I need this?
If we want to parameterize test cases, we have 2 ways: pytest parametrize or pytest-subtests
pytest parametrize:
demo like below:
import pytest
from loguru import logger
@pytest.mark.parametrize('i', range(3))
def test_parametrize(i):
logger.info(f'test {i=}')
There are some disadvantages of this way:
- the 2nd parameter in pytest.mark.parametrize is a function, it will execute when module import, even test is not executed, if it is complex and time waste, will need a long time
- pytest.mark.parametrize can only pass simple data type to the test function, it is a little hard to use complex data type and do complex operation
pytest-subtests
use pytest-subtests in https://pypi.org/project/pytest-subtests/
I find there is disadvantage in this way:
- It is not compatible with Allure, it will generate an Allure report with no subtest results
I want some ways both have the advantages of pytest-subtests and allure.
So this library is born based on pytest-subtests and allure.
ChangeLog
- 0.1.4
- support allure.dynamic.parent_suite, suite, sub_suite...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for allure_subtests-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ff08e74b190ae9def8997ff7aff6d08cb5a875a21c5c5b960a6c9ca66147b55 |
|
MD5 | 4987f1705cd97b8f4ba7d11584c0761a |
|
BLAKE2b-256 | 49a10a4fda2c62fd0863f6bd88fde8667b6459c3f57bcf3934ce1fc7962ce1f3 |