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

WIP: Add a simple way to mark tests as xfail inside test #10096

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manueljacob
Copy link
Contributor

Closes #9027.

TODO: discuss API in #9027
TODO: write documentation
TODO: write changelog entry
TODO: add me to AUTHORS
TODO: fix linting errors
TODO: write proper commit message

TODO: discuss API in pytest-dev#9027
TODO: write documentation
TODO: write changelog entry
TODO: add me to AUTHORS
TODO: fix linting errors
TODO: write proper commit message
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

If we introduce that contextvar, we need to do it correct and aware of threads and async



def pytest_runtest_protocol(item: Item, nextitem: Optional[Item]) -> None:
current_item_var.set(item)
Copy link
Member

Choose a reason for hiding this comment

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

This is completely missing cleanup and self protection, it's basically breaking pytester in a hidden way


def expect_failure(**kwargs) -> None:
# TODO: raise proper error, test
assert kwargs.get("run", True)
Copy link
Member

Choose a reason for hiding this comment

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

Just give the function a correct signature, run is not part of the equation here, don't allow it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That’s what I did in 8c4ca32. I didn’t get the typing right, so I put 58f5e7b on top. I’ll try again with the approach from 8c4ca32 with correct typing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See also #10094.

TODO: put _XfailMarkDecorator fix into its own pull request
TODO: squash into previous commit
@obestwalter
Copy link
Member

@manueljacob would you like to pick this up again and see, if we can get it merged or would it be better to close and have a fresh go at a later point?

@obestwalter obestwalter added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add run parameter to pytest.xfail()
3 participants