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: Custom marker for GitHub #572

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

Conversation

Akasurde
Copy link
Member

@Akasurde Akasurde commented Mar 2, 2022

Created custom marker for skipping test if GitHub issue/pull is open.

Fixes: #495

Created custom marker for skipping test if GitHub issue/pull
is open.

Signed-off-by: Abhijeet Kasurde <[email protected]>
gh_markers = [mark.args[0] for mark in item.iter_markers(name="github")]
if gh_markers:
issue_url = gh_markers[0]
with urllib.request.urlopen(issue_url) as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this require using the API endpoint for an Issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You will need to specify the marker like this -

import pytest

@pytest.mark.github('https://api.github.com/repos/ansible/receptor/issues/441')
def test_c():
    print("This is Test C")

I choose this routine in order to avoid additional dependency on third-party library.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can simplify the logic further to specify only the issue number or pull request number. But for starters, I think this OK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pretty difficult to use. Normally you'd just visit an issue in your browser. We should be able to copy / paste that URL instead of having to construct this API endpoint. We use https://github.com/jlaska/pytest-github in other projects, so we're not maintaining anything extra by also using it here.

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.

Add plugin pytest-github to the receptorctl test suite
2 participants