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
Closed
Assignees
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed

Comments

@skirpichev
Copy link


$ 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 problem that needs to be addressed label Feb 10, 2018
skirpichev added a commit to skirpichev/diofant that referenced this issue Feb 11, 2018
See pytest-dev/pytest#3203.  Option was introduced (in 2f426cd)
to show warnings, which now displayed without one.
@feuillemorte
Copy link
Contributor

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
Copy link
Member

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?

@nicoddemus nicoddemus added the topic: reporting related to terminal output and user-facing messages and errors label Feb 21, 2018
@feuillemorte
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

4 participants