@@ -892,8 +892,9 @@ here is a little example implemented via a local plugin:
892
892
.. code-block :: python
893
893
894
894
# content of conftest.py
895
-
895
+ from typing import Dict
896
896
import pytest
897
+ from pytest import StashKey, CollectReport
897
898
898
899
phase_report_key = StashKey[Dict[str , CollectReport]]()
899
900
@@ -951,10 +952,46 @@ and run it:
951
952
.. code-block :: pytest
952
953
953
954
$ pytest -s test_module.py
954
- ImportError while loading conftest '/home/sweet/project/conftest.py'.
955
- conftest.py:4: in <module>
956
- phase_report_key = StashKey[Dict[str, CollectReport]]()
957
- E NameError: name 'StashKey' is not defined
955
+ =========================== test session starts ============================
956
+ platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
957
+ rootdir: /home/sweet/project
958
+ collected 3 items
959
+
960
+ test_module.py Esetting up a test failed or skipped test_module.py::test_setup_fails
961
+ Fexecuting test failed or skipped test_module.py::test_call_fails
962
+ F
963
+
964
+ ================================== ERRORS ==================================
965
+ ____________________ ERROR at setup of test_setup_fails ____________________
966
+
967
+ @pytest.fixture
968
+ def other():
969
+ > assert 0
970
+ E assert 0
971
+
972
+ test_module.py:7: AssertionError
973
+ ================================= FAILURES =================================
974
+ _____________________________ test_call_fails ______________________________
975
+
976
+ something = None
977
+
978
+ def test_call_fails(something):
979
+ > assert 0
980
+ E assert 0
981
+
982
+ test_module.py:15: AssertionError
983
+ ________________________________ test_fail2 ________________________________
984
+
985
+ def test_fail2():
986
+ > assert 0
987
+ E assert 0
988
+
989
+ test_module.py:19: AssertionError
990
+ ========================= short test summary info ==========================
991
+ FAILED test_module.py::test_call_fails - assert 0
992
+ FAILED test_module.py::test_fail2 - assert 0
993
+ ERROR test_module.py::test_setup_fails - assert 0
994
+ ======================== 2 failed, 1 error in 0.12s ========================
958
995
959
996
You'll see that the fixture finalizers could use the precise reporting
960
997
information.
0 commit comments