Skip to content
New issue

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

Output repeats #286

Open
GammaGames opened this issue Sep 17, 2024 · 0 comments
Open

Output repeats #286

GammaGames opened this issue Sep 17, 2024 · 0 comments

Comments

@GammaGames
Copy link

GammaGames commented Sep 17, 2024

Command used to run pytest

pytest -rP

Test file

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

Output

When pytest-sugar is not installed:

============================================= 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
@GammaGames GammaGames changed the title Outputs multiple lines Output repeats Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant