Skip to content

Print test name before result in verbose mode #223

@hmaarrfk

Description

@hmaarrfk

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions