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

Add offline mode to skip tests that require an internet connection #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Luflosi
Copy link

@Luflosi Luflosi commented Oct 1, 2021

Closes #133.

I found a way to make make skipping the tests very elegant, requiring only @mark.online().
This comes at the expense of a little more code in conftest.py, the use of the get_closest_marker() function, which seems a bit hacky IMO and the additional file pytest.ini at the root of the project which registers the custom mark to avoid a warning.
If you think this is not worth it, I can just change this PR to skip the tests like in the APIO example.
I marked this PR as a draft to better indicate that I need your opinion on how to do this.

@ikreymer
Copy link
Member

ikreymer commented Oct 5, 2021

Thanks! I think that looks reasonable, and actually instead of pytest.ini, you can just add it to conftest.py so its all in one place. I think the following should work:

def pytest_configure(config):
    config.addinivalue_line(
        "markers", "online: marks tests as requiring an internet connection"
    )

@Luflosi Luflosi marked this pull request as ready for review October 6, 2021 08:55
@Luflosi
Copy link
Author

Luflosi commented Oct 6, 2021

Yes, that works, thanks. Please review.

@Luflosi
Copy link
Author

Luflosi commented Nov 11, 2021

Do you maybe have some time to review this please?

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

Successfully merging this pull request may close these issues.

Offline tests
2 participants