Skip to content

Show total progress in terminal during testing #2657

Closed

Description

@nicoddemus

This is a proposal to change the terminal output while running tests to include the total tests ran so far and the total tests still to run, or percentage of the total tests executed so far.

Currently here's the normal pytest output (minus header):

============================= test session starts =============================
collected 1909 items

testing\acceptance_test.py ...............s................................x.............
testing\deprecated_test.py ......
testing\test_argcomplete.py ss
testing\test_assertion.py ........................................................................s.......
<snip>

What I propose is:

============================= test session starts ===============================
collected 1909 items

testing\acceptance_test.py ...............s............................ [44/1909]
                           ....x.............                           [62/1909]
testing\deprecated_test.py ......                                       [68/1909]
testing\test_argcomplete.py ss                                          [70/1909]
testing\test_assertion.py ............................................ [114/1909]
                          ............................s.......         [150/1909] 
<snip>

This would be a better view of the overall progress and how much tests are still left on the run.

Alternatively instead of showing test counts we could just show a percentage of the total run so far:

============================= test session starts ===============================
collected 1909 items

testing\acceptance_test.py ...............s................................ [ 2%]
                           ....x.........                                   [ 3%]
testing\deprecated_test.py ......                                           [ 3%]
testing\test_argcomplete.py ss                                              [ 3%]
testing\test_assertion.py ................................................. [ 5%]
                          ............................s.                    [ 7%] 
<snip>

Thoughts? cc @RonnyPfannschmidt @hpk42 @The-Compiler @hackebrot

Side note

This idea came to be because it Jenkins (it seems) only updates its console view when the process outputs a new line. When running with xdist, pytest only prints a . per test, only printing a new line at the end of the session, so the output windows doesn't update until the end of the run.

Changing the output to the one proposed here would fix that and also provide a nice user experience (IMO).

Activity

  1. added
    type: proposal
    topic: reporting
    on Aug 4, 2017
  2. nicoddemus commented on Aug 4, 2017

    @nicoddemus
    MemberAuthor

    Note: this would work with xdist outside of the box as well. 😉

  3. RonnyPfannschmidt commented on Aug 4, 2017

    @RonnyPfannschmidt
    Member

    doesnt pytest-sugar already implement a much nicer version of this

  4. nicoddemus commented on Aug 4, 2017

    @nicoddemus
    MemberAuthor

    Indeed, but pytest-sugar only works on Linux. 😬

  5. The-Compiler commented on Aug 4, 2017

    @The-Compiler
    Member

    I like it! pytest-sugar also has a lot of other problems (it being very fancy is also causing issues), and good defaults matter.

  6. RonnyPfannschmidt commented on Aug 4, 2017

    @RonnyPfannschmidt
    Member

    according to Teemu/pytest-sugar#49 (comment) it only a codepage issue and solvable by a single command

  7. RonnyPfannschmidt commented on Aug 4, 2017

    @RonnyPfannschmidt
    Member

    well, im fine with enhancing terminal output, but i do wonder how much harder it will make the removal of the current terminalwriter mess

    also note that currently the terminal width determination of pylib is completely broken for output capture situation

  8. nicoddemus commented on Aug 4, 2017

    @nicoddemus
    MemberAuthor

    according to Teemu/pytest-sugar#49 (comment) it only a codepage issue and solvable by a single command

    Didn't know that, thanks for the link!

    well, im fine with enhancing terminal output, but i do wonder how much harder it will make the removal of the current terminalwriter mess

    AFAIK it won't make things worse (it will depend on tw.write as does all the other code which depends on terminalwriter) but I'm of course willing to abort the idea if the implementation gets too messy.

  9. self-assigned this
    on Aug 11, 2017
  10. added
    type: enhancement
    and removed
    type: proposal
    on Aug 31, 2017
  11. ApaDoctor commented on Oct 5, 2017

    @ApaDoctor
    Contributor

    does anybody works on this issue?
    i want to take it

  12. RonnyPfannschmidt commented on Oct 5, 2017

    @RonnyPfannschmidt
    Member

    @nicoddemus do you have any plans/attempts already started, if thats not the case, i propose we let @ApaDoctor try

  13. nicoddemus commented on Oct 5, 2017

    @nicoddemus
    MemberAuthor

    I have a work in progress at home actually, I don't think it is pushed to me fork though. @ApaDoctor let me push that branch when I get home so you can take a look. This is a little tricky than thought at first because we have to "hook" into terminal's writer to ensure we are tracking the correct number of chars written to the current line so far.

  14. added 2 commits that reference this issue on Nov 21, 2017
    dab8893
    3a5dbab
  15. Teemu commented on Dec 12, 2017

    @Teemu

    This is pretty cool 👍

    I think if this existed 4 years ago I would have never started pytest-sugar project.

  16. nicoddemus commented on Dec 12, 2017

    @nicoddemus
    MemberAuthor

    Which would be a shame because pytest-sugar terminal is awesome 😁

  17. kevinpohlmeier commented on Apr 6, 2022

    @kevinpohlmeier

    When I added a pytest.ini file with the following contents, I started seeing progress on my xdist runs:

    [pytest]
    log_cli = 1
    log_cli_level = WARN

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

Metadata

Metadata

Assignees

Labels

topic: reportingtype: enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions