-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fixtures cannot be retrieved in pytest_runtest_makereport function for tests that are skipped during setup with the pytest.mark.skip marker #13101
Comments
skipped tests don't get their fixtures filled thats intended behavior |
This issue is stale because it has the |
I would say that skipped tests during setup should get their fixtures. Why did you make an exception with skipped tests during setup? |
If they will not run at all, then it makes little sense to do their setup and teardown phase. Why do you think that they should get filled, can you elaborate? |
Sure, this is my use case. I want to recover the reason that was passed as argument to the skip marker I want to parse the I want to define an issue pattern like So, this is why I want to read the fixture to see if I detect the pattern in the This is why I also want to do it with skipped tests during setup. |
The easiest way to do this is to use an own marker and call skip in an autouse fixture |
But still, with custom-made markers, you need to use fixtures. |
or maybe I can get the marker like this : |
@RonnyPfannschmidt is suggesting something like: @pytest.fixture(autouse=True)
def check_skip_because(request: pytest.FixtureRequest) -> None:
if marker := request.node.get_closest_marker("skip_because"):
reason = marker.args[0]
# Parse link from `reason` and add to report.
pytest.skip(f"Skipped due to {reason}") And use like this: @pytest.mark.skip_because("See PROJ-123")
def test_skipped(my_fixture):
pass IOW, you do not use the builtin |
I am trying to retrieve the fixtures when a test has been skipped with the
skip
marker.But this is impossible because pytest doesn't pass the fixture of skipped tests during setup to the pytest_runtest_makereport function
Steps to reproduce:
my_fixture
inconftest.py
fileconftest.py
fileThis piece of code doesn't work because
item.funcargs = {}
anditem.funcargs['request']
will raise an exception.pytest doesn't retrieve the fixtures of skipped tests during setup. Why?
Tested with pytest 8.3.4
The text was updated successfully, but these errors were encountered: