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

pytest shows 0% test statistics after 3.4.0 with --capture argument #3203

Closed
skirpichev opened this Issue Feb 10, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@skirpichev
Copy link

skirpichev commented Feb 10, 2018


$ cat test_a.py 
def test_1():
    pass
def test_2():
    pass
$ cat test_b.py 
def test_1():
    pass
def test_2():
    pass

Before 3.4.0 I get:

$ py.test --capture=no test_*
============================= test session starts ==============================
platform linux -- Python 3.5.3, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
rootdir: /home/sk/test, inifile:
plugins: cov-2.4.0
collected 4 items                                                              

test_a.py ..                                                             [ 50%]
test_b.py ..                                                             [100%]

=========================== 4 passed in 0.04 seconds ===========================

But since last release:

$ py.test --capture=no test_*
============================= test session starts ==============================
platform linux -- Python 3.5.3, pytest-3.4.0, py-1.5.2, pluggy-0.6.0
rootdir: /home/sk/test, inifile:
plugins: cov-2.4.0
collected 4 items                                                              

test_a.py ..                                                             [  0%]
test_b.py ..

=========================== 4 passed in 0.04 seconds ===========================

@pytestbot pytestbot added the type: bug label Feb 10, 2018

skirpichev added a commit to skirpichev/diofant that referenced this issue Feb 11, 2018

pytest: removed --capture option
See pytest-dev/pytest#3203.  Option was introduced (in 2f426cd)
to show warnings, which now displayed without one.
@feuillemorte

This comment has been minimized.

Copy link
Member

feuillemorte commented Feb 11, 2018

The problem is here:

pytest/_pytest/terminal.py

Lines 158 to 166 in e7bcc85

def _determine_show_progress_info(self):
"""Return True if we should display progress information based on the current config"""
# do not show progress if we are not capturing output (#3038)
if self.config.getoption('capture') == 'no':
return False
# do not show progress if we are showing fixture setup/teardown
if self.config.getoption('setupshow'):
return False
return self.config.getini('console_output_style') == 'progress'

        # do not show progress if we are not capturing output (#3038)
        if self.config.getoption('capture') == 'no':
            return False

Why we don't need to show a progress when capture option is off? If it is right may be we need to hide percentage? because [0%] is not good point here, I think

I can fix it but I don't know what is right :)

@nicoddemus

This comment has been minimized.

Copy link
Member

nicoddemus commented Feb 21, 2018

Why we don't need to show a progress when capture option is off?

Because since we are not capturing output, the output of the tests can create quite a mess in the terminal and printing the progress indicator really only adds to the mess so it was decided to not print it at all (also we can't really track the correct position where to put the progress indicator because the output is not coming through the TerminalReporter, which tracks the number of characters written per line). The example shown here does not suffer from this because the tests do not actually print anything, but that's not easy to detect.

So we really should just find the bit of code which "slipped" that check and not print the indicator in that case. 😁

Want to tackle this @feuillemorte?

@feuillemorte

This comment has been minimized.

Copy link
Member

feuillemorte commented Feb 23, 2018

@nicoddemus yes, then I take it and will delete indicator in this case :) Thank you!

@feuillemorte feuillemorte self-assigned this Feb 23, 2018

feuillemorte added a commit to feuillemorte/pytest that referenced this issue Feb 26, 2018

feuillemorte added a commit to feuillemorte/pytest that referenced this issue Feb 26, 2018

feuillemorte added a commit to feuillemorte/pytest that referenced this issue Feb 26, 2018

nicoddemus added a commit that referenced this issue Feb 27, 2018

Merge pull request #3263 from feuillemorte/3203-remove-statistic-indi…
…cator

#3203 Remove progress when no-capture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.