bugfix: fix imports for simple example
This commit is contained in:
		
							parent
							
								
									ba969d2ae7
								
							
						
					
					
						commit
						54864f0c9b
					
				|  | @ -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 <module> | ||||
|         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. | ||||
|  |  | |||
|  | @ -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`: | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue