From 28bdba8ec221af6fb0464546ed5df0f740ab69a8 Mon Sep 17 00:00:00 2001 From: paveltovchigrechko Date: Fri, 21 Mar 2025 16:52:03 +0100 Subject: [PATCH] Change fixture example, add allure in Pytest options --- pyproject.toml | 21 +++++++++++++++++++-- test/test_sum.py | 10 ++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aaeea86..b21ebf8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,20 @@ classifiers = [ ] dependencies = [ # Put the project's production dependencies here: - + "allure-pytest==2.13.5", + "allure-python-commons==2.13.5", + "attrs==25.1.0", + "exceptiongroup==1.2.2", + "flake8==7.1.2", + "flake8-builtins==2.5.0", + "iniconfig==2.0.0", + "mccabe==0.7.0", + "packaging==24.2", + "pluggy==1.5.0", + "pycodestyle==2.12.1", + "pyflakes==3.2.0", + "pytest==8.3.4", + "tomli==2.2.1", ] [project.optional-dependencies] @@ -26,4 +39,8 @@ dev = [ ] [tool.pytest.ini_options] -testpaths = ["test"] \ No newline at end of file +testpaths = ["test"] + +addopts = [ + "--alluredir", "allure-results", +] \ No newline at end of file diff --git a/test/test_sum.py b/test/test_sum.py index e14a4b6..d31c177 100644 --- a/test/test_sum.py +++ b/test/test_sum.py @@ -1,11 +1,9 @@ -import allure import pytest def test_sum(): assert 1 + 2 == 3 - def test_sum_loop(): data = [ [1, 2, 3], @@ -15,22 +13,22 @@ def test_sum_loop(): for x, y, ttl in data: assert x + y == ttl - data = [ [1, 2, 3], [-1, 1, 0], [0, 0, 0] ] +def prepare_test_data(param): + return data[param] @pytest.mark.parametrize("x,y,ttl", data) def test_sum_parameterized(x, y, ttl): assert x + y == ttl - -@pytest.fixture(params=data) +@pytest.fixture(params=[0, 1, 2]) def sum_arguments(request): - return request.param[0], request.param[1], request.param[2] + yield prepare_test_data(request.param) def test_sum_simple(sum_arguments): x, y, ttl = sum_arguments