bugfix: fix imports for simple example

This commit is contained in:
Ronny Pfannschmidt 2023-03-17 21:56:41 +01:00
parent ba969d2ae7
commit 54864f0c9b
2 changed files with 43 additions and 6 deletions

View File

@ -892,8 +892,9 @@ here is a little example implemented via a local plugin:
.. code-block:: python .. code-block:: python
# content of conftest.py # content of conftest.py
from typing import Dict
import pytest import pytest
from pytest import StashKey, CollectReport
phase_report_key = StashKey[Dict[str, CollectReport]]() phase_report_key = StashKey[Dict[str, CollectReport]]()
@ -951,10 +952,46 @@ and run it:
.. code-block:: pytest .. code-block:: pytest
$ pytest -s test_module.py $ pytest -s test_module.py
ImportError while loading conftest '/home/sweet/project/conftest.py'. =========================== test session starts ============================
conftest.py:4: in <module> platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
phase_report_key = StashKey[Dict[str, CollectReport]]() rootdir: /home/sweet/project
E NameError: name 'StashKey' is not defined collected 3 items
test_module.py Esetting up a test failed or skipped test_module.py::test_setup_fails
Fexecuting test failed or skipped test_module.py::test_call_fails
F
================================== ERRORS ==================================
____________________ ERROR at setup of test_setup_fails ____________________
@pytest.fixture
def other():
> assert 0
E assert 0
test_module.py:7: AssertionError
================================= FAILURES =================================
_____________________________ test_call_fails ______________________________
something = None
def test_call_fails(something):
> assert 0
E assert 0
test_module.py:15: AssertionError
________________________________ test_fail2 ________________________________
def test_fail2():
> assert 0
E assert 0
test_module.py:19: AssertionError
========================= short test summary info ==========================
FAILED test_module.py::test_call_fails - assert 0
FAILED test_module.py::test_fail2 - assert 0
ERROR test_module.py::test_setup_fails - assert 0
======================== 2 failed, 1 error in 0.12s ========================
You'll see that the fixture finalizers could use the precise reporting You'll see that the fixture finalizers could use the precise reporting
information. information.

View File

@ -22,7 +22,7 @@ Install ``pytest``
.. code-block:: bash .. code-block:: bash
$ pytest --version $ pytest --version
pytest 7.2.0.dev533+gd08c8e337 pytest 7.2.0.dev534+ga2c84caaa.d20230317
.. _`simpletest`: .. _`simpletest`: