pytest-sugar icon indicating copy to clipboard operation
pytest-sugar copied to clipboard

No output while setup is running

Open mbrt opened this issue 6 years ago • 2 comments

If a test has a long setup fixture, it takes a long time before the first test is executed. Without pytest-sugar, pytest already outputs the test name itself, so you get immediate feedback of what test is trying to execute. With pytest-sugar you get no output, so it appears to be stuck (but it's instead waiting for the setup to complete).

Command used to run py.test

py.test test_example.py

Test file

import time
import pytest

@pytest.fixture
def long_setup():
    time.sleep(10)

def test(long_setup):
    pass

Output

The output is correct, but for 10 seconds the screen looks like this:

Test session starts (platform: linux, Python 3.6.4, pytest 3.3.2, pytest-sugar 0.9.0)
rootdir: /home/micheleb/local/test/pytest, inifile:
plugins: sugar-0.9.0

Expected instead:

Test session starts (platform: linux, Python 3.6.4, pytest 3.3.2, pytest-sugar 0.9.0)
rootdir: /home/micheleb/local/test/pytest, inifile:
plugins: sugar-0.9.0

 test_example.py

mbrt avatar Jan 29 '18 14:01 mbrt

my 2c : this is also problematic for long running tests.

I'm using hypothesis which does property testing: a single test is run many times against randomly generated data. This way a single test can take multiple seconds so outputting it name before it result is really important (especially working with async or threads where deadlocks can occurs).

touilleMan avatar Mar 21 '18 09:03 touilleMan

Maybe it could display an ellipsis ("…") for the setup phase already? Would be good if this could get deferred, e.g. so that it only happens after e.g. 0.5s.

blueyed avatar Aug 29 '18 17:08 blueyed

I think this was solved.

Let me know if it is still relevant

Teemu avatar Nov 08 '22 18:11 Teemu