2024-08-02 12:56:22 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2024-11-15 12:30:43 +00:00
|
|
|
def parametrize_fixture() -> list[int]:
|
|
|
|
return [1, 2, 3]
|
|
|
|
|
|
|
|
|
2024-08-02 12:56:22 +00:00
|
|
|
@pytest.fixture(
|
|
|
|
scope="function",
|
|
|
|
params=[
|
|
|
|
pytest.param(1),
|
|
|
|
pytest.param(2),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def object_size(request: pytest.FixtureRequest):
|
|
|
|
return request.param
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def file_path(object_size):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
@allure.title("[Function] Object fixture")
|
|
|
|
@pytest.fixture(scope="function")
|
|
|
|
def object_fixture(file_path):
|
|
|
|
return file_path
|
|
|
|
|
|
|
|
|
|
|
|
@allure.title("[Session] Parametrized fixture")
|
|
|
|
@pytest.fixture(
|
|
|
|
scope="session",
|
|
|
|
params=[
|
|
|
|
pytest.param(1, marks=[pytest.mark.test_1]),
|
|
|
|
pytest.param(2, marks=[pytest.mark.test_2]),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def parametrized_fixture(request: pytest.FixtureRequest):
|
|
|
|
return request.param
|
2024-11-15 12:30:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
@allure.title("[Session] Optional parametrized fixture")
|
|
|
|
@pytest.fixture(
|
|
|
|
scope="session",
|
|
|
|
params=[parametrize_fixture()],
|
|
|
|
)
|
|
|
|
def optional_parametrized_fixture(request: pytest.FixtureRequest):
|
|
|
|
return request.param
|