Skip to content

Commit 054ca5c

Browse files
mwychungnicoddemus
authored andcommitted
Updated the section of Typing Temporary Directories and Paths
1 parent c105afb commit 054ca5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/en/how-to/types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ While parameterized tests can involve varied data types and that annotations sim
116116

117117

118118
Typing for Monkeypatching
119-
--------------------------
119+
-------------------------
120120
Monkeypatching modifies functions or environment variables during runtime.
121121
Adding typing, such as `monkeypatch: pytest.MonkeyPatch`, clarifies the expected patching behaviour and reduces the risk of errors.
122122

@@ -177,7 +177,6 @@ Typing Temporary Directories and Paths
177177
Temporary directories and paths are commonly used in pytest to create isolated environments for testing file and directory operations.
178178
The `tmp_path` and `tmpdir` fixtures provide these capabilities.
179179
Adding typing annotations enhances clarity about the types of objects these fixtures return, which is particularly useful when performing file operations.
180-
It also prevents misuse of monkeypatch by clarifies its API and expected inputs.
181180

182181
Below examples are based on the pytest documentation for `Temporary Directories and Files in tests <https://github.com/pytest-dev/pytest/blob/main/doc/en/how-to/tmp_path.rst>`_, with the addition of typing annotations.
183182

@@ -225,6 +224,7 @@ Typing `tmp_path: Path` explicitly defines it as a Path object, improving code r
225224
# compute and test histogram
226225
227226
Here:
227+
228228
- **tmp_path_factory: pytest.TempPathFactory:** Indicates that `tmp_path_factory` is an instance of pytest’s `TempPathFactory`, responsible for creating temporary directories and paths during testing.
229229
- **fn: Path:** Identifies that `fn` is a `Path` object, emphasizing its role as a file path and clarifying the expected file operations.
230230
- **Return type -> Path:** Specifies the fixture returns a `Path` object, clarifying its expected structure.

0 commit comments

Comments
 (0)