We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytest -rP
import pytest @pytest.fixture def before_after(request): print(f"Before test - {request.param[0]}") yield print(f"After test - {request.param[1]}") @pytest.mark.parametrize("before_after", [[1, 2]], indirect=True) def test_1(before_after): print("Test 1") assert True @pytest.mark.parametrize("before_after", [["a", "b"]], indirect=True) def test_2(before_after): print("Test 2") assert True
When pytest-sugar is not installed:
pytest-sugar
============================================= test session starts ============================================= platform linux -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0 rootdir: /test collected 2 items test/test_main.py .. [100%] =================================================== PASSES ==================================================== ____________________________________________ test_1[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - 1 -------------------------------------------- Captured stdout call --------------------------------------------- Test 1 ------------------------------------------ Captured stdout teardown ------------------------------------------- After test - 2 ____________________________________________ test_2[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - a -------------------------------------------- Captured stdout call --------------------------------------------- Test 2 ------------------------------------------ Captured stdout teardown ------------------------------------------- After test - b ============================================== 2 passed in 0.02s ==============================================
When pytest-sugar is installed:
Test session starts (platform: linux, Python 3.12.6, pytest 8.3.3, pytest-sugar 1.0.0) rootdir: /test plugins: sugar-1.0.0 collected 2 items test_main.py ✓✓ 100% ██████████ =================================================== PASSES ==================================================== ____________________________________________ test_1[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - 1 ____________________________________________ test_1[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - 1 -------------------------------------------- Captured stdout call --------------------------------------------- Test 1 ____________________________________________ test_1[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - 1 -------------------------------------------- Captured stdout call --------------------------------------------- Test 1 ------------------------------------------ Captured stdout teardown ------------------------------------------- After test - 2 ____________________________________________ test_2[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - a ____________________________________________ test_2[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - a -------------------------------------------- Captured stdout call --------------------------------------------- Test 2 ____________________________________________ test_2[before_after0] ____________________________________________ -------------------------------------------- Captured stdout setup -------------------------------------------- Before test - a -------------------------------------------- Captured stdout call --------------------------------------------- Test 2 ------------------------------------------ Captured stdout teardown ------------------------------------------- After test - b Results (0.03s): 2 passed
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Command used to run pytest
pytest -rP
Test file
Output
When
pytest-sugar
is not installed:When
pytest-sugar
is installed:The text was updated successfully, but these errors were encountered: