Skip to content

Commit d8c6923

Browse files
authored
chore: upgrade docs dependencies and fix warnings (#217)
1 parent 1dc6abf commit d8c6923

File tree

9 files changed

+409
-357
lines changed

9 files changed

+409
-357
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ runs:
2020
uses: actions/setup-python@v4
2121
with:
2222
python-version: ${{ inputs.python-version }}
23+
allow-prereleases: true
2324

2425
- name: "Set up dependency cache"
2526
uses: actions/cache@v3

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [Ubuntu, Windows, macOS]
17-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
17+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
1818
steps:
1919
- name: "Check out repository"
2020
uses: actions/checkout@v3

decoy/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Decoy:
2121
You should create a new Decoy instance before each test and call
2222
[`reset`][decoy.Decoy.reset] after each test. If you use the
2323
[`decoy` pytest fixture][decoy.pytest_plugin.decoy], this is done
24-
automatically. See the [setup guide](../#setup) for more details.
24+
automatically. See the [setup guide][] for more details.
2525
2626
!!! example
2727
```python
@@ -32,6 +32,8 @@ class Decoy:
3232
3333
decoy.reset()
3434
```
35+
36+
[setup guide]: index.md#setup
3537
"""
3638

3739
def __init__(self) -> None:
@@ -59,7 +61,7 @@ def mock(
5961
) -> Any:
6062
"""Create a mock. See the [mock creation guide] for more details.
6163
62-
[mock creation guide]: ../usage/create/
64+
[mock creation guide]: usage/create.md
6365
6466
Arguments:
6567
cls: A class definition that the mock should imitate.
@@ -94,7 +96,7 @@ def when(
9496
) -> "Stub[ReturnT]":
9597
"""Create a [`Stub`][decoy.Stub] configuration using a rehearsal call.
9698
97-
See [stubbing usage guide](../usage/when/) for more details.
99+
See [stubbing usage guide](usage/when.md) for more details.
98100
99101
Arguments:
100102
_rehearsal_result: The return value of a rehearsal, used for typechecking.
@@ -133,7 +135,7 @@ def verify(
133135
) -> None:
134136
"""Verify a mock was called using one or more rehearsals.
135137
136-
See [verification usage guide](../usage/verify/) for more details.
138+
See [verification usage guide](usage/verify.md) for more details.
137139
138140
Arguments:
139141
_rehearsal_results: The return value of rehearsals, unused except
@@ -174,7 +176,7 @@ def test_create_something(decoy: Decoy):
174176
def prop(self, _rehearsal_result: ReturnT) -> "Prop[ReturnT]":
175177
"""Create property setter and deleter rehearsals.
176178
177-
See [property mocking guide](../advanced/properties/) for more details.
179+
See [property mocking guide](advanced/properties.md) for more details.
178180
179181
Arguments:
180182
_rehearsal_result: The property to mock, for typechecking.
@@ -202,7 +204,7 @@ def reset(self) -> None:
202204
class Stub(Generic[ReturnT]):
203205
"""A rehearsed Stub that can be used to configure mock behaviors.
204206
205-
See [stubbing usage guide](../usage/when/) for more details.
207+
See [stubbing usage guide](usage/when.md) for more details.
206208
"""
207209

208210
def __init__(self, core: StubCore) -> None:
@@ -291,7 +293,7 @@ def then_enter_with(
291293
The wrapping context manager is compatible with both the synchronous and
292294
asynchronous context manager interfaces.
293295
294-
See the [context manager usage guide](../advanced/context-managers/)
296+
See the [context manager usage guide](advanced/context-managers.md)
295297
for more details.
296298
297299
Arguments:
@@ -303,7 +305,7 @@ def then_enter_with(
303305
class Prop(Generic[ReturnT]):
304306
"""Rehearsal creator for mocking property setters and deleters.
305307
306-
See [property mocking guide](../advanced/properties/) for more details.
308+
See [property mocking guide](advanced/properties.md) for more details.
307309
"""
308310

309311
def __init__(self, core: PropCore) -> None:

decoy/errors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
See the [errors guide][] for more details.
44
5-
[errors guide]: ../usage/errors-and-warnings/#errors
5+
[errors guide]: usage/errors-and-warnings.md#errors
66
"""
77
from typing import Optional, Sequence
88

@@ -15,7 +15,7 @@ class MockNameRequiredError(ValueError):
1515
1616
See the [MockNameRequiredError guide][] for more details.
1717
18-
[MockNameRequiredError guide]: ../usage/errors-and-warnings/#mocknamerequirederror
18+
[MockNameRequiredError guide]: usage/errors-and-warnings.md#mocknamerequirederror
1919
"""
2020

2121
def __init__(self) -> None:
@@ -32,7 +32,7 @@ class MissingRehearsalError(ValueError):
3232
3333
See the [MissingRehearsalError guide][] for more details.
3434
35-
[MissingRehearsalError guide]: ../usage/errors-and-warnings/#missingrehearsalerror
35+
[MissingRehearsalError guide]: usage/errors-and-warnings.md#missingrehearsalerror
3636
"""
3737

3838
def __init__(self) -> None:
@@ -46,7 +46,7 @@ class MockNotAsyncError(TypeError):
4646
to a synchronous stub's `then_do` method.
4747
See the [MockNotAsyncError guide][] for more details.
4848
49-
[MockNotAsyncError guide]: ../usage/errors-and-warnings/#mocknotasyncerror
49+
[MockNotAsyncError guide]: usage/errors-and-warnings.md#mocknotasyncerror
5050
"""
5151

5252

@@ -55,7 +55,7 @@ class VerifyError(AssertionError):
5555
5656
See [spying with verify][] for more details.
5757
58-
[spying with verify]: ../usage/verify/
58+
[spying with verify]: usage/verify.md
5959
6060
Attributes:
6161
rehearsals: Rehearsals that were being verified.

decoy/matchers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
66
Matchers help you loosen assertions where strict adherence to an exact value
77
is not relevant to what you're trying to test.
8+
See the [matchers guide][] for more details.
9+
10+
[matchers guide]: usage/matchers.md
811
912
!!! example
1013
```python

decoy/warnings.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
See the [warnings guide][] for more details.
44
5-
[warnings guide]: ../usage/errors-and-warnings/#warnings
5+
[warnings guide]: usage/errors-and-warnings.md#warnings
66
"""
77
import os
88
from typing import Sequence
@@ -25,9 +25,9 @@ class MiscalledStubWarning(DecoyWarning):
2525
- Configured as a stub with [`when`][decoy.Decoy.when]
2626
- Called with arguments that do not match any configured behaviors
2727
28-
See the [MiscalledStubWarning guide] for more details.
28+
See the [MiscalledStubWarning guide][] for more details.
2929
30-
[MiscalledStubWarning guide]: ../usage/errors-and-warnings/#miscalledstubwarning
30+
[MiscalledStubWarning guide]: usage/errors-and-warnings.md#miscalledstubwarning
3131
3232
Attributes:
3333
rehearsals: The mocks's configured rehearsals.
@@ -70,7 +70,7 @@ class RedundantVerifyWarning(DecoyWarning):
7070
7171
See the [RedundantVerifyWarning guide][] for more details.
7272
73-
[RedundantVerifyWarning guide]: ../usage/errors-and-warnings/#redundantverifywarning
73+
[RedundantVerifyWarning guide]: usage/errors-and-warnings.md#redundantverifywarning
7474
"""
7575

7676
def __init__(self, rehearsal: VerifyRehearsal) -> None:
@@ -91,8 +91,7 @@ class IncorrectCallWarning(DecoyWarning):
9191
9292
If a call to a Decoy mock is incorrect according to `inspect.signature`,
9393
this warning will be raised.
94-
9594
See the [IncorrectCallWarning guide][] for more details.
9695
97-
[IncorrectCallWarning guide]: ../usage/errors-and-warnings/#incorrectcallwarning
96+
[IncorrectCallWarning guide]: usage/errors-and-warnings.md#incorrectcallwarning
9897
"""

docs/usage/errors-and-warnings.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ my_mock = decoy.mock(name="my_mock")
6161

6262
Decoy uses Python's [warnings system][] to provide feedback about dubious mock usage that isn't _technically_ incorrect. These warnings won't fail your tests, but you probably want to fix them.
6363

64+
[warnings system]: https://docs.python.org/3/library/warnings.html
65+
6466
### DecoyWarning
6567

6668
A [decoy.warnings.DecoyWarning][] is the base class of all warnings raised by Decoy. This warning will never be raised directly, but can be used in [warning filters][].
@@ -72,6 +74,8 @@ For example, you could set all Decoy warnings to errors or ignore them all entir
7274
pytestmark = pytest.mark.filterwarnings("ignore::decoy.warnings.DecoyWarning")
7375
```
7476

77+
[warning filters]: https://docs.pytest.org/en/latest/how-to/capture-warnings.html
78+
7579
### MiscalledStubWarning
7680

7781
A [decoy.warnings.MiscalledStubWarning][] is a warning provided mostly for productivity convenience. If you configure a stub but your code under test calls the stub incorrectly, it can sometimes be difficult to immediately figure out what went wrong. This warning exists to alert you if:
@@ -139,6 +143,8 @@ tests/test_example.py::test_subject
139143

140144
These warnings tell us that something probably went wrong with how the dependency was called, allowing us to fix the issue and move on.
141145

146+
[unittest.mock]: https://docs.python.org/3/library/unittest.mock.html
147+
142148
### RedundantVerifyWarning
143149

144150
A [decoy.warnings.RedundantVerifyWarning][] is a warning provided to prevent you from writing redundant and over-constraining `verify` calls to mocks that have been configured with `when`.
@@ -194,7 +200,3 @@ spy(val="world") # ok
194200
spy(wrong_name="ah!") # triggers an IncorrectCallWarning
195201
spy("too", "many", "args") # triggers an IncorrectCallWarning
196202
```
197-
198-
[warnings system]: https://docs.python.org/3/library/warnings.html
199-
[warning filters]: https://docs.pytest.org/en/latest/how-to/capture-warnings.html
200-
[unittest.mock]: https://docs.python.org/3/library/unittest.mock.html

0 commit comments

Comments
 (0)