decoy 2.4.0__py3-none-any.whl → 2.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
decoy/pytest_plugin.py
CHANGED
|
@@ -5,21 +5,32 @@ fixture without modifying any other pytest behavior. Its usage is optional
|
|
|
5
5
|
but highly recommended.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from typing import Iterable
|
|
8
|
+
from typing import TYPE_CHECKING, Iterable, Union, get_type_hints
|
|
9
9
|
|
|
10
10
|
import pytest
|
|
11
11
|
|
|
12
12
|
from decoy import Decoy
|
|
13
13
|
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from decoy.next import Decoy as DecoyNext
|
|
16
|
+
|
|
14
17
|
|
|
15
18
|
@pytest.fixture()
|
|
16
|
-
def decoy(
|
|
19
|
+
def decoy(
|
|
20
|
+
request: pytest.FixtureRequest,
|
|
21
|
+
) -> "Iterable[Union[Decoy, DecoyNext]]":
|
|
17
22
|
"""Get a [decoy.Decoy][] container and [reset it][decoy.Decoy.reset] after the test.
|
|
18
23
|
|
|
19
24
|
This function is function-scoped [pytest fixture][] that will be
|
|
20
25
|
automatically inserted by the plugin.
|
|
21
26
|
|
|
27
|
+
!!! tip
|
|
28
|
+
|
|
29
|
+
This fixture will automatically opt-into the [v3 preview API][v3-preview]
|
|
30
|
+
if annotated with `decoy.next.Decoy`.
|
|
31
|
+
|
|
22
32
|
[pytest fixture]: https://docs.pytest.org/en/latest/how-to/fixtures.html
|
|
33
|
+
[v3-preview]: ./v3/about.md
|
|
23
34
|
|
|
24
35
|
!!! example
|
|
25
36
|
```python
|
|
@@ -28,6 +39,20 @@ def decoy() -> Iterable[Decoy]:
|
|
|
28
39
|
# ...
|
|
29
40
|
```
|
|
30
41
|
"""
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
try:
|
|
43
|
+
decoy_hint = get_type_hints(request.function).get("decoy")
|
|
44
|
+
is_next = decoy_hint.__module__.startswith("decoy.next")
|
|
45
|
+
|
|
46
|
+
# purely defensive, probably won't ever raise
|
|
47
|
+
except Exception: # pragma: no cover
|
|
48
|
+
is_next = False
|
|
49
|
+
|
|
50
|
+
if is_next:
|
|
51
|
+
from decoy.next import Decoy as DecoyNext
|
|
52
|
+
|
|
53
|
+
with DecoyNext.create() as decoy_next:
|
|
54
|
+
yield decoy_next
|
|
55
|
+
else:
|
|
56
|
+
decoy = Decoy()
|
|
57
|
+
yield decoy
|
|
58
|
+
decoy.reset()
|
|
@@ -21,7 +21,7 @@ decoy/next/_internal/verify.py,sha256=CEgb7Di-uJskObO2hIycvCgTLixVd4BYCZvHkTvWXR
|
|
|
21
21
|
decoy/next/_internal/warnings.py,sha256=59T3hs3x2AcGp6jAUEEbq2pLgFMKO2QatE-1ep0Tlxg,1182
|
|
22
22
|
decoy/next/_internal/when.py,sha256=WtV2U_LIvGbkYgo8CfocUxo3ZDjdlnbV8gtUp6lmBSU,4376
|
|
23
23
|
decoy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
decoy/pytest_plugin.py,sha256=
|
|
24
|
+
decoy/pytest_plugin.py,sha256=y_5soxLEGJXo_EmPXcpw_axLcyStgVROkU-SDaVYCEM,1611
|
|
25
25
|
decoy/spy.py,sha256=G3rEHAx2yWQaucOs8fQoB-Hap8vejPrzYcxBca6XbeQ,7581
|
|
26
26
|
decoy/spy_core.py,sha256=b3PTgCkYnijT08ak_iRUKnA95FnmspSRmT8cs_YtjtM,7965
|
|
27
27
|
decoy/spy_events.py,sha256=PFTfkgN7CVWfbVoSSUMSaCSxfRrUMd7U419iwQ1Xofg,2383
|
|
@@ -32,7 +32,7 @@ decoy/types.py,sha256=LXzky6T0RXvS53NoPpVgCi3KVV6KCyB6EvnBl0NaKug,404
|
|
|
32
32
|
decoy/verifier.py,sha256=3ZVqaUJPjaNM9Nue3FK6Zzj15qWskX2CEQXoe_yjUEs,1586
|
|
33
33
|
decoy/warning_checker.py,sha256=OOkcrr_I98Pzs3o9UUNgaihJDHwNiu1LlcEK9hi5ZFs,3577
|
|
34
34
|
decoy/warnings.py,sha256=DLdX1ABPk6QvhJWt5s98uR7rCQFQdJJjSPPXRSX0nXA,3203
|
|
35
|
-
decoy-2.
|
|
36
|
-
decoy-2.
|
|
37
|
-
decoy-2.
|
|
38
|
-
decoy-2.
|
|
35
|
+
decoy-2.5.0.dist-info/WHEEL,sha256=iHtWm8nRfs0VRdCYVXocAWFW8ppjHL-uTJkAdZJKOBM,80
|
|
36
|
+
decoy-2.5.0.dist-info/entry_points.txt,sha256=En3V0KZt-83nTeWFpVB5KTotgxuUETePl7HesB81W64,40
|
|
37
|
+
decoy-2.5.0.dist-info/METADATA,sha256=s_d-w2xrobK880yLspMDWUQ78cXP2QIJBcwetW-jX0Y,6980
|
|
38
|
+
decoy-2.5.0.dist-info/RECORD,,
|
|
File without changes
|