Skip to content

Commit c616f52

Browse files
committed
Move to explanation
1 parent b3b981e commit c616f52

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

doc/en/explanation/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ Explanation
1212
fixtures
1313
goodpractices
1414
pythonpath
15+
types
1516
ci
1617
flaky

doc/en/how-to/types.rst doc/en/explanation/types.rst

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
.. _types:
22

3-
Enhancing Type Annotations with Pytest
4-
======================================
3+
Typing in pytest
4+
================
55

6-
This page assumes the reader is familiar with Python's typing system and its advantages.
7-
For more information, refer to `Python's Typing Documentation <https://docs.python.org/3/library/typing.html>`_.
6+
.. note::
7+
This page assumes the reader is familiar with Python's typing system and its advantages.
8+
9+
For more information, refer to `Python's Typing Documentation <https://docs.python.org/3/library/typing.html>`_.
810

911
Why type tests?
1012
---------------
@@ -37,8 +39,8 @@ Note the code above has 100% coverage, but the bug is not caught (of course the
3739

3840

3941

40-
Typing fixtures
41-
---------------
42+
Using typing in test suites
43+
---------------------------
4244

4345
To type fixtures in pytest, just add normal types to the fixture functions -- there is nothing special that needs to be done just because of the `fixture` decorator.
4446

@@ -61,20 +63,16 @@ In the same manner, the fixtures passed to test functions need be annotated with
6163
From the POV of the type checker, it does not matter that `sample_fixture` is actually a fixture managed by pytest, all it matters to it is that `sample_fixture` is a parameter of type `int`.
6264

6365

64-
The same logic applies to `@pytest.mark.parametrize`:
66+
The same logic applies to :ref:`@pytest.mark.parametrize <@pytest.mark.parametrize>`:
6567

6668
.. code-block:: python
6769
68-
import pytest
69-
7070
7171
@pytest.mark.parametrize("input_value, expected_output", [(1, 2), (5, 6), (10, 11)])
7272
def test_increment(input_value: int, expected_output: int) -> None:
7373
assert input_value + 1 == expected_output
7474
7575
76-
77-
7876
The same logic applies when typing fixture functions which receive other fixtures:
7977

8078
.. code-block:: python
@@ -84,8 +82,6 @@ The same logic applies when typing fixture functions which receive other fixture
8482
monkeypatch.setenv("USER", "TestingUser")
8583
8684
87-
88-
8985
Conclusion
9086
----------
9187

0 commit comments

Comments
 (0)