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

Any way to access the current iteration count? #52

Open
acohen716 opened this issue Aug 3, 2021 · 3 comments
Open

Any way to access the current iteration count? #52

acohen716 opened this issue Aug 3, 2021 · 3 comments

Comments

@acohen716
Copy link

If I'd like to use/display the current iteration count, is there any way to do that from within the Python test code?

@acohen716
Copy link
Author

I've found this but it doesn't seem like the correct approach to handling this...

@joeyshelton
Copy link

I came here wondering the same thing. This would be a small feature addition and it would be very helpful. Although, the creators of pytest-repeat may want to avoid the ability for a test's behavior to be dependent on iteration number.

@acohen716
Copy link
Author

I personally decided to use the same logic as in the stackoverflow post in our conftest.py in order to log the current test and iteration as follows:

import logging
import pytest

log = logging.getLogger(__name__)

@pytest.fixture(scope="function", autouse=True)
def log_test_function_start(request):
    """Logs test name at start of test, helps identify currently running test and iteration"""
    log.info("#################################################################")
    log.info("Starting execution of test: %s", request.node.name)
    log.info("##################################################################")

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

No branches or pull requests

3 participants