Comments (7)
Example code exhibiting the problem:
import pytest_check as check
import pytest
@pytest.mark.xfail()
def test_fail_check():
check.equal(1, 2)
Note: I did verify that the code works with pytest 5.3.5.
It was the pytest 5.4.0 update that caused the failure
from pytest-check.
The code in question is probably the pytest_runtest_makereport()
hook:
@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
evalxfail = getattr(item, "_evalxfail", None)
failures = check_methods.get_failures()
check_methods.clear_failures()
if failures:
if evalxfail and evalxfail.wasvalid() and evalxfail.istrue():
report.outcome = "skipped"
report.wasxfail = evalxfail.getexplanation()
elif outcome._result.longreprtext.startswith("[XPASS(strict)]"):
report.outcome = "skipped"
report.wasxfail = "\n".join(failures)
else:
summary = "Failed Checks: {}".format(len(failures))
longrepr = ["\n".join(failures)]
longrepr.append("-" * 60)
longrepr.append(summary)
report.longrepr = "\n".join(longrepr)
report.outcome = "failed"
This is where I'm setting failue, xfail, etc.
My guess is the format of the _evalxfail object may have changed.
from pytest-check.
Ok. well, now that I pinpoint where I'm abusing the pytest internals manipulate the results, I'm not surprised that relying on _evalxfail and _result eventually broke.
This will take some head scratching to solve.
May be prudent to simplify this plugin and state that xfail isn't supported.
from pytest-check.
this is definitely something that I think should be exposed by pytest to plugins, but I'm not quite sure how at the moment 🤔
here's an UGLY workaround (which really just restores the access this plugin was doing before)
try:
evalxfail = item._evalxfail
except AttributeError:
from _pytest.skipping import evalxfail_key
evalxfail = item._store[evalxfail_key]
from pytest-check.
thank you!
from pytest-check.
I'm not sure if this is reliable but you may be able to loop through the report
object's keyword
dict and look for the xfail key. The keyword should show up if xfail is added programmatically or with pytest.mark.xfail
. This also would eliminate the use of protected objects.
from pytest-check.
I like this idea. I'll try it sometime soon-ish.
For now, I'll close this with the workaround in place
from pytest-check.
Related Issues (20)
- Feature request: Add new test outcome status ? HOT 1
- Test is not marked as xfailed when pytest.xfail() called after a failure. HOT 2
- RFE: is it possible to start making github releases?🤔 HOT 6
- pytest check is not reporting all failures distributed across multiple python functions or setup fixture called within a test function HOT 3
- Linux environment does not have version 2.1.5 HOT 3
- Document & test: custom error message for check.raises HOT 2
- raises match argument HOT 1
- Is the 'raises' parameter in xfail ignored? HOT 1
- `pytest-check` causes `pytest-xdist` testing to fail HOT 1
- Add new check type: match - use regular expressions to tests againgst a string HOT 1
- pytest_html HOT 1
- How to have all failure on logging pytestfile HOT 1
- [v2.2.3] ExceptionRepr creation is not compatible with pytest < 7.3. HOT 2
- INTERNALERROR after upgrading package to 2.2.3 or 2.2.4 version HOT 5
- Add an xdist test
- Incorrect arguments to `ExceptionRepr` HOT 5
- d7afe0d6570c24d8d9ecc4443be9a765a0b85c2c HOT 1
- d7afe0d6570c24d8d9ecc4443be9a765a0b85c2c
- type-hinting the project
- Include a `check.match` and `check.not_match` for regex comparison
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-check.