Skip to content

Commit 6481543

Browse files
authored
docs: fix typos in docs and type annotations (#149)
1 parent 25dcdf1 commit 6481543

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_remove_todo(decoy: Decoy) -> None:
128128

129129
subject.remove("abc123")
130130

131-
decoy.verify(todo_store.remove(id="abc123"))
131+
decoy.verify(todo_store.remove(id="abc123"), times=1)
132132
```
133133

134134
See [spying with verify][] for more details.

docs/advanced/context-managers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ From this test, we could sketch out the following dependency APIs...
4646
```python
4747
# config.py
4848
import contextlib
49-
from typing import Iterator
49+
from typing import Generator
5050

5151
class Config:
5252
def read(self, name: str) -> bool:
5353
...
5454

5555
class ConfigLoader:
5656
@contextlib.contextmanager
57-
def load(self) -> Iterator[Config]:
57+
def load(self) -> Generator[Config, None, None]:
5858
...
5959
```
6060

@@ -65,7 +65,7 @@ class ConfigLoader:
6565
from .config import Config, ConfigLoader
6666

6767
class Core:
68-
def __init__(self, config_laoder: ConfigLoader) -> None:
68+
def __init__(self, config_loader: ConfigLoader) -> None:
6969
self._config_loader = config_loader
7070

7171
def get_config(self, name: str) -> bool:
@@ -78,7 +78,7 @@ class Core:
7878

7979
## General context managers
8080

81-
A context manager is simply an object with both `__enter__` and `__exit__` methods defined. Decoy mocks have both these methods defined, so they are compatible with the `with` statement. In the author's opinion, tests that mock `__enter__` and `__exit__` (or any double-underscore method) are harder to read and understand than tests that do not, so generator-based context managers should be prefered where applicable.
81+
A context manager is simply an object with both `__enter__` and `__exit__` methods defined. Decoy mocks have both these methods defined, so they are compatible with the `with` statement. In the author's opinion, tests that mock `__enter__` and `__exit__` (or any double-underscore method) are harder to read and understand than tests that do not, so generator-based context managers should be preferred where applicable.
8282

8383
Using our earlier example, maybe you'd prefer to use a single `Config` dependency to both load the configuration resource and read values.
8484

@@ -101,7 +101,7 @@ def test_loads_config(decoy: Decoy) -> None:
101101
"""Ensure test fails if subject calls `read` after exit."""
102102
decoy.when(
103103
config.read("some_flag")
104-
).then_raise(AssertionError("Context manager was exitted"))
104+
).then_raise(AssertionError("Context manager was exited"))
105105

106106
decoy.when(config.__enter__()).then_do(_handle_enter)
107107
decoy.when(config.__exit__(None, None, None)).then_do(_handle_exit)
@@ -175,7 +175,7 @@ async def test_loads_config(decoy: Decoy) -> None:
175175
"""Ensure test fails if subject calls `read` after exit."""
176176
decoy.when(
177177
config.read("some_flag")
178-
).then_raise(AssertionError("Context manager was exitted"))
178+
).then_raise(AssertionError("Context manager was exited"))
179179

180180
decoy.when(await config.__aenter__()).then_do(_handle_enter)
181181
decoy.when(await config.__aexit__()).then_do(_handle_exit)

docs/advanced/properties.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ dep = decoy.mock()
6363

6464
decoy.when(
6565
decoy.prop(dep.some_property).set(42)
66-
).then_return(RuntimeError("oh no"))
66+
).then_raise(RuntimeError("oh no"))
6767

6868
decoy.when(
6969
decoy.prop(dep.some_property).delete()
70-
).then_return(RuntimeError("what a disaster"))
70+
).then_raise(RuntimeError("what a disaster"))
7171

7272
with pytest.raises(RuntimeError, match="oh no"):
7373
dep.some_property = 42

tests/test_decoy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Smoke and acceptance tests for main Decoy interface."""
22
import contextlib
33
import sys
4-
from typing import Any, AsyncIterator, ContextManager, Iterator, Optional
4+
from typing import Any, AsyncIterator, ContextManager, Generator, Optional
55

66
import pytest
77

@@ -267,7 +267,7 @@ def get_value(self) -> int:
267267

268268
class _ValueReaderLoader:
269269
@contextlib.contextmanager
270-
def get_value_reader(self) -> Iterator[_ValueReader]:
270+
def get_value_reader(self) -> Generator[_ValueReader, None, None]:
271271
...
272272

273273
value_reader_loader = decoy.mock(cls=_ValueReaderLoader)

tests/typing/test_typing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@
119119
skip: sys.version_info < (3, 7)
120120
main: |
121121
import contextlib
122-
from typing import Iterator
122+
from typing import Generator
123123
from decoy import Decoy
124124
125125
@contextlib.contextmanager
126-
def do_thing(input: str) -> Iterator[int]:
126+
def do_thing(input: str) -> Generator[int, None, None]:
127127
yield 42
128128
129129
decoy = Decoy()

0 commit comments

Comments
 (0)