Comments (9)
This is a very good point. Are you interested in working on a fix?
from pytest-check.
I am happy to contribute on this.
pytest has many options for --tb (https://docs.pytest.org/en/7.0.x/how-to/output.html#modifying-python-traceback-printing). Is it necessary to support all of them in pytest-check or just some of them?
from pytest-check.
I was just trying to reproduce the problem and don't see a problem.
test_foo.py
from pytest_check import check
def test_multiple_failures():
a = (1, 2, 3)
b = (3, 2, 1)
with check:
assert a == b
with check:
assert b == a
Normal multiple failures:
$ pytest test_foo.py
========================= test session starts ==========================
collected 1 item
test_foo.py F [100%]
=============================== FAILURES ===============================
________________________ test_multiple_failures ________________________
FAILURE: assert (1, 2, 3) == (3, 2, 1)
At index 0 diff: 1 != 3
Use -v to get more diff
test_foo.py:6 in test_multiple_failures() -> with check:
FAILURE: assert (3, 2, 1) == (1, 2, 3)
At index 0 diff: 3 != 1
Use -v to get more diff
test_foo.py:8 in test_multiple_failures() -> with check:
------------------------------------------------------------
Failed Checks: 2
======================= short test summary info ========================
FAILED test_foo.py::test_multiple_failures
========================== 1 failed in 0.02s ===========================
With --tb=no
:
$ pytest --tb=no test_foo.py
========================= test session starts ==========================
collected 1 item
test_foo.py F [100%]
======================= short test summary info ========================
FAILED test_foo.py::test_multiple_failures
========================== 1 failed in 0.02s ===========================
Isn't this what you were asking for?
from pytest-check.
With --tb=no
, the console output is correct. But the command I used is pytest --junitxml=output_pytest.xml --tb=no test_foo.py
, because I need to output the results and use it to generate html report. In the xml file, the content is wrong
When use pytest_check
, with/without --tb=no
, the xml content always includes the traceback.
import pytest_check as check
def test_multiple_failures():
a = (1, 2, 3)
b = (3, 2, 1)
check.equal(a, b)
xml content
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="1" skipped="0" tests="1" time="0.047" timestamp="2022-04-12T16:24:07.419257" hostname="yizhous-mbp2"><testcase classname="test_foo" name="test_multiple_failures" time="0.020"><failure message="FAILURE: assert (1, 2, 3) == (3, 2, 1) At index 0 diff: 1 != 3 Use -v to get the full diff test_foo.py:8 in test_multiple_failures() -> check.equal(a, b) ------------------------------------------------------------ Failed Checks: 1">FAILURE:
assert (1, 2, 3) == (3, 2, 1)
At index 0 diff: 1 != 3
Use -v to get the full diff
test_foo.py:8 in test_multiple_failures() -> check.equal(a, b)
------------------------------------------------------------
Failed Checks: 1</failure></testcase></testsuite></testsuites>
When just use assert, with--tb=no
, the xml content won't include the traceback info.
def test_multiple_failures():
a = (1, 2, 3)
b = (3, 2, 1)
assert a == b
xml content
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="1" skipped="0" tests="1" time="0.024" timestamp="2022-04-12T16:13:42.053330" hostname="mbp2"><testcase classname="test_foo" name="test_multiple_failures" time="0.001"><failure message="assert (1, 2, 3) == (3, 2, 1) At index 0 diff: 1 != 3 Use -v to get the full diff">E assert (1, 2, 3) == (3, 2, 1)
At index 0 diff: 1 != 3
Use -v to get the full diff</failure></testcase></testsuite></testsuites>
from pytest-check.
Ah. Ok.
Regarding "Is it necessary to support all of them in pytest-check or just some of them?", let's start with just supporting --tb=no and take it from there.
from pytest-check.
PR created. #81
from pytest-check.
Thank you. I’ll take a look later this week.
from pytest-check.
Changing title from "Cannot disable the traceback in the error message"
to "--tb=no should remove tracebacks from xml output"
from pytest-check.
fixed by version 1.0.10
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.