-
-
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
AttributeError: 'Function' object has no attribute '_skipped_by_mark' #3074
Comments
GitMate.io thinks the contributor most likely able to help you is @nicoddemus. |
Needed until pytest-dev/pytest#3074 is fixed.
The fix for this should be as simple as: diff --git a/_pytest/skipping.py b/_pytest/skipping.py
index a1e5b438..11ddab4d 100644
--- a/_pytest/skipping.py
+++ b/_pytest/skipping.py
@@ -261,7 +261,8 @@ def pytest_runtest_makereport(item, call):
else:
rep.outcome = "passed"
rep.wasxfail = explanation
- elif item._skipped_by_mark and rep.skipped and type(rep.longrepr) is tuple:
+ elif hasattr(item, '_skipped_by_mark') and item._skipped_by_mark and rep.skipped and \
+ type(rep.longrepr) is tuple:
# skipped by mark.skipif; change the location of the failure
# to point to the item definition, otherwise it will display
# the location of where the skip exception was raised within pytest I'd be happy to submit a pull request, but I was unsure what if any test was appropriate. This seems like a mistake that any hook could make at any time and thus isn't really specific to the skipping plugin. |
for better consistency i propose the use of |
for documentative purposes, https://github.com/pytest-dev/pytest/pull/3075/files#diff-9696819f160fbd3aa8ce9363c38990e9L172 is the line that triggers the issue - the try first hook that skips simply happens before the other call - that detail was my oversight back when switching the variable names we might want to evaluate the code-base for more such pitfalls in future |
pytest-dev/pytest#3074 is resolved as of 3.4.0.
pytest-dev/pytest#3074 is resolved as of 3.4.0.
pytest-dev/pytest#3074 is resolved as of 3.4.0.
pytest-dev/pytest#3074 is resolved as of 3.4.0.
If test execution aborts before the skipping module's
pytest_runtest_setup
hook executes (e.g., viapytest.skip()
in an earlier setup hook), the skipping module'spytest_runtest_makereport
hook fails with:The skipping module's reporting hook assumes that its setup hook executed and thus that it is safe to read the
_skipped_by_mark
attribute on the test item. If test execution aborts in an earlier setup hook, however, this assumption will be incorrect and its reporting hook will fail.Note: This error is the same as seen in #2982 and #2974, but, unlike those issues, is not masking a separate, root error: it is the root error.
Example
Setup
Note: Also fails on pytest 3.3.0. Succeeds on pytest 3.2.5.
Scenario
conftest.py
test_skip.py
Results
The text was updated successfully, but these errors were encountered: