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

Print test name before result in verbose mode #223

Open
hmaarrfk opened this issue Aug 16, 2021 · 4 comments
Open

Print test name before result in verbose mode #223

hmaarrfk opened this issue Aug 16, 2021 · 4 comments

Comments

@hmaarrfk
Copy link

Without pytest-sugar, when running pytest in verbose mode, the name of the current test is printed immediately.

This is very useful for long running tests since you know which test is hanging, and which test might be killed.

However, with pytest-sugar, the name of the test is only printed when the test succeeds.

I've provided an example of the code to reproduce this as well some minimal environment information.

The current environment in question is running Python 3.9.

Let me know if there is any more information you need to recreate the bug/"missing feature".

Conda environment

(mcam_dev) ✔ ~/Downloads
09:13 $ mamba list pytest

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.2) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████

# packages in environment at /home/mark/mambaforge/envs/mcam_dev:
#
# Name                    Version                   Build  Channel
pytest                    6.2.4            py39hf3d152e_0    conda-forge
pytest-env                0.6.2                      py_0    conda-forge
pytest-forked             1.3.0              pyhd3deb0d_0    conda-forge
pytest-localftpserver     1.1.2              pyhd8ed1ab_0    conda-forge
pytest-qt                 4.0.2              pyhd8ed1ab_0    conda-forge
pytest-sugar              0.9.4              pyh9f0ad1d_1    conda-forge
pytest-timeout            1.4.2              pyh9f0ad1d_0    conda-forge
pytest-xdist              2.3.0              pyhd8ed1ab_0    conda-forge

Command used to run pytest

pytest test_me.py

Test file test_me.py

from time import sleep
import pytest


@pytest.mark.parametrize('time', range(5))
def test_sleep(time):
    sleep(time)

Output

Without pytest-sugar. Notice how I captured the name of test_sleep[2] before the result of the test appeared.
image

With pytest-sugar. Notice how I was able to capture the screenshot while test_sleep[4] was running, but before the name of the test appeared
image

@Tbruno25
Copy link

Tbruno25 commented Jan 8, 2022

I also think this would be a great enhancement and is very useful.

@brettdh
Copy link

brettdh commented Jul 25, 2023

I would also love to see this, in verbose and non-verbose mode. There could perhaps be an icon or spinner used when a test is running, before it finishes.

@justinmayer
Copy link
Collaborator

@hmaarrfk / @Tbruno25 / @brettdh: Since you have expressed an interest in this feature, would you like to contribute to the project and work on implementing it?

@brettdh
Copy link

brettdh commented Jul 26, 2023

Yep! I may have time to work on a PR this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants