From 54864f0c9b44dead80a0f4d6601a2da1e0203a19 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Fri, 17 Mar 2023 21:56:41 +0100 Subject: [PATCH] bugfix: fix imports for simple example --- doc/en/example/simple.rst | 47 ++++++++++++++++++++++++++++++++++---- doc/en/getting-started.rst | 2 +- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index d07585b97..fa3e68ce9 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -892,8 +892,9 @@ here is a little example implemented via a local plugin: .. code-block:: python # content of conftest.py - + from typing import Dict import pytest + from pytest import StashKey, CollectReport phase_report_key = StashKey[Dict[str, CollectReport]]() @@ -951,10 +952,46 @@ and run it: .. code-block:: pytest $ pytest -s test_module.py - ImportError while loading conftest '/home/sweet/project/conftest.py'. - conftest.py:4: in - phase_report_key = StashKey[Dict[str, CollectReport]]() - E NameError: name 'StashKey' is not defined + =========================== test session starts ============================ + platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y + rootdir: /home/sweet/project + 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 information. diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index ccb56779d..89bc1aa02 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 7.2.0.dev533+gd08c8e337 + pytest 7.2.0.dev534+ga2c84caaa.d20230317 .. _`simpletest`: