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

sub-steps progress report #3235

Closed
gaborbernat opened this issue Feb 19, 2018 · 15 comments
Closed

sub-steps progress report #3235

gaborbernat opened this issue Feb 19, 2018 · 15 comments
Labels
status: help wanted developers would like help from experts on this topic type: enhancement new feature or API change, should be merged into features branch type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@gaborbernat
Copy link
Contributor

gaborbernat commented Feb 19, 2018

Would it be possible to add sub-steps reporting to test? :-) e.g. imagine I have some integration test cases that run reasonably long (e.g. 2 minutes, I would like to give some progress report to the user, to not let him wander around what's happening). E.g. with -vvvv to say:

plugins/test_init_integration.py::test_flow
    create db
    populate tables
    simulate_parallel_add
   ...

Do you guys think that's a good idea?

@RonnyPfannschmidt
Copy link
Member

linking - #153 for documentative purposes

@RonnyPfannschmidt RonnyPfannschmidt added type: enhancement new feature or API change, should be merged into features branch status: help wanted developers would like help from experts on this topic type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature labels Feb 19, 2018
@nicoddemus
Copy link
Member

This can be implemented a simple fixture:

import pytest

@pytest.fixture
def print_sub_report(pytestconfig):
    dummy = lambda *args: None
    #print('option', pytestconfig.getoption('verbose'))
    if pytestconfig.getoption('verbose') <= 0:
        return dummy

    terminal_reporter = pytestconfig.pluginmanager.getplugin('terminalreporter')
    if terminal_reporter is None:
    	return dummy

    first_call = [True]

    def print_sub_report(msg):
    	if first_call[0]:
    		terminal_reporter.write('\n')
    		first_call[0] = False
    	terminal_reporter.write('  ' + msg + '\n')

    return print_sub_report


def test_something(print_sub_report):
	print_sub_report('create db')
	print_sub_report('populate tables')
	print_sub_report('simulate_parallel_add')

Output:

collected 1 item

foo.py::test_something
  create db
  populate tables
  simulate_parallel_add
PASSED                                                                                                           [100%]

============================================== 1 passed in 0.04 seconds ===============================================

While adding this to the core is simple, not sure if a separate plugin would be better at least as a first interaction, to nail down the API and see which other integrations would be necessary (junitxml comes to mind for example).

@nicoddemus
Copy link
Member

nicoddemus commented Feb 19, 2018

This is very similar to #1602, although the intents are different (informational vs debugging).

@gaborbernat
Copy link
Contributor Author

@nicoddemus I like what you propose. Do you want to release it as a plugin, and let';s see where it goes, or should I?

@nicoddemus
Copy link
Member

@gaborbernat feel free to go for it if you have the time! 👍

@gaborbernat
Copy link
Contributor Author

gaborbernat commented Apr 8, 2018

@nicoddemus it's not finished and posted yet to PyPi, but can you have a first look at it https://github.com/gaborbernat/pytest-print

Will publish next week but would be nice an eye on it before. The timestamps thing mirrors how https://docs.python.org/3/library/logging.html#logrecord-attributes relativeCreated works.

Thanks!

PS. Should we move it under pytest-dev?

@nicoddemus
Copy link
Member

Looks nice to me. I'm fine with moving under pytest-dev as well. 😁

@gaborbernat
Copy link
Contributor Author

@nicoddemus https://pypi.org/project/pytest-print/, done :-D there is a test failing on windows, seems the pytest flag is not picked up for some reason, will check

@gaborbernat
Copy link
Contributor Author

@nicoddemus want to invite the project under pytest then? 😃

@nicoddemus
Copy link
Member

Sure! Transfer the project to me and I will complete the transfer.

@gaborbernat
Copy link
Contributor Author

Repository transfer to nicoddemus requested

@nicoddemus
Copy link
Member

Done. 😁

@nicoddemus
Copy link
Member

@gaborbernat could you also add me as maintainer on PyPI? Thanks!

@gaborbernat
Copy link
Contributor Author

Done 👍

@nicoddemus
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted developers would like help from experts on this topic type: enhancement new feature or API change, should be merged into features branch type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

3 participants