-
-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
Description
I have found that
pytest-qt/src/pytestqt/exceptions.py
Lines 90 to 95 in cdad310
| def _is_exception_capture_enabled(item): | |
| """returns if exception capture is disabled for the given test item.""" | |
| disabled = get_marker(item, "qt_no_exception_capture") or item.config.getini( | |
| "qt_no_exception_capture" | |
| ) | |
| return not disabled |
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 #573 (comment)
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.