pytest-dev / pytest-dev/pytest-qt
`qt_no_exception_capture = 0` is not working
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 455
- Forks
- 72
- Avg merge
- 12h 26m
- Merged PRs (30d)
- 1
Description
I have found that
always returns False because disabled is either "0" or "1" (as strings) or Mark(...), depending on whether I use pytest.mark.qt_no_exception_capture or qt_no_exception_capture = 1, all of which evaluate to True.
Originally posted by @bersbersbers in https://github.com/pytest-dev/pytest-qt/issues/573#issuecomment-2412981118
Example code:
diff --git a/pytest.ini b/pytest.ini
index 9ade678..2c1ef1e 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -4,3 +4,4 @@ addopts = --strict-markers --strict-config
xfail_strict = true
markers =
filterwarnings: pytest's filterwarnings marker
+qt_no_exception_capture = 0
diff --git a/src/pytestqt/exceptions.py b/src/pytestqt/exceptions.py
index d342876..afbd5c5 100644
--- a/src/pytestqt/exceptions.py
+++ b/src/pytestqt/exceptions.py
@@ -92,6 +92,7 @@ def _is_exception_capture_enabled(item):
disabled = get_marker(item, "qt_no_exception_capture") or item.config.getini(
"qt_no_exception_capture"
)
+ print(not disabled)
return not disabled
diff --git a/tests/test_bug.py b/tests/test_bug.py
new file mode 100644
index 0000000..8008047
--- /dev/null
+++ b/tests/test_bug.py
@@ -0,0 +1,32 @@
+import pytest
+from pytestqt.exceptions import _is_exception_capture_enabled
+
+@pytest.fixture(scope="session", autouse=True)
+def check_is_exception_capture_enabled(request):
+ session = request.node
+ for item in session.items:
+ print(_is_exception_capture_enabled(item))
+
+def test_nomarker():
+ pass
+
+@pytest.mark.qt_no_exception_capture
+def test_marker():
+ pass
+
+@pytest.mark.qt_no_exception_capture(0)
+def test_marker_zero():
+ pass
+
+@pytest.mark.qt_no_exception_capture(1)
+def test_marker_one():
+ pass
+
+@pytest.mark.qt_no_exception_capture(False)
+def test_marker_false():
+ pass
+
+@pytest.mark.qt_no_exception_capture(True)
+def test_marker_true():
+ pass
+
Then run pip install -e . && pytest -s tests\test_bug.py and see all False.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/pytestqt/exceptions.py at _is_exception_capture_enabled and reproduce the behavior with the example in tests/test_bug.py. Run pip install -e . && pytest -s tests\test_bug.py, then add regression coverage for the configuration and marker cases so their exception-capture status is evaluated correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100