decoy 2.2.1__tar.gz → 2.3.0__tar.gz
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-2.2.1 → decoy-2.3.0}/PKG-INFO +5 -14
- {decoy-2.2.1 → decoy-2.3.0}/README.md +1 -8
- {decoy-2.2.1 → decoy-2.3.0}/decoy/matchers.py +54 -35
- {decoy-2.2.1 → decoy-2.3.0}/pyproject.toml +35 -34
- decoy-2.2.1/LICENSE +0 -21
- {decoy-2.2.1 → decoy-2.3.0}/decoy/__init__.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/call_handler.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/context_managers.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/core.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/errors.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/mypy/__init__.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/mypy/plugin.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/py.typed +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/pytest_plugin.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/spy.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/spy_core.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/spy_events.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/spy_log.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/stringify.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/stub_store.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/types.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/verifier.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/warning_checker.py +0 -0
- {decoy-2.2.1 → decoy-2.3.0}/decoy/warnings.py +0 -0
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: decoy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Opinionated mocking library for Python
|
|
5
|
-
License-Expression: MIT
|
|
6
|
-
License-File: LICENSE
|
|
7
5
|
Author: Michael Cousins
|
|
8
|
-
Author-email: michael@cousins.io
|
|
9
|
-
|
|
6
|
+
Author-email: Michael Cousins <michael@cousins.io>>
|
|
7
|
+
License-Expression: MIT
|
|
10
8
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
9
|
Classifier: Intended Audience :: Developers
|
|
12
10
|
Classifier: Operating System :: OS Independent
|
|
13
11
|
Classifier: Topic :: Software Development :: Testing
|
|
14
12
|
Classifier: Topic :: Software Development :: Testing :: Mocking
|
|
15
13
|
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.7
|
|
16
15
|
Project-URL: Changelog, https://github.com/mcous/decoy/releases
|
|
17
16
|
Project-URL: Documentation, https://michael.cousins.io/decoy/
|
|
18
17
|
Project-URL: Homepage, https://michael.cousins.io/decoy/
|
|
@@ -30,7 +29,7 @@ Description-Content-Type: text/markdown
|
|
|
30
29
|
<a title="Code Coverage" href="https://app.codecov.io/gh/mcous/decoy/"><img src="https://img.shields.io/codecov/c/github/mcous/decoy?style=flat-square"></a>
|
|
31
30
|
<a title="License" href="https://github.com/mcous/decoy/blob/main/LICENSE"><img src="https://img.shields.io/github/license/mcous/decoy?style=flat-square"></a>
|
|
32
31
|
<a title="PyPI Version"href="https://pypi.org/project/decoy/"><img src="https://img.shields.io/pypi/v/decoy?style=flat-square"></a>
|
|
33
|
-
<a title="Supported Python Versions" href="https://pypi.org/project/decoy/"><img src="https://img.shields.io/
|
|
32
|
+
<a title="Supported Python Versions" href="https://pypi.org/project/decoy/"><img src="https://img.shields.io/python/required-version-toml?style=flat-square&tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fmcous%2Fdecoy%2Fmain%2Fpyproject.toml"></a>
|
|
34
33
|
</p>
|
|
35
34
|
<p>
|
|
36
35
|
<a href="https://michael.cousins.io/decoy/" class="decoy-hidden">Usage guide and documentation</a>
|
|
@@ -44,14 +43,7 @@ Decoy mocks are **async/await** and **type-checking** friendly. Decoy is heavily
|
|
|
44
43
|
## Install
|
|
45
44
|
|
|
46
45
|
```bash
|
|
47
|
-
# pip
|
|
48
46
|
pip install decoy
|
|
49
|
-
|
|
50
|
-
# poetry
|
|
51
|
-
poetry add --dev decoy
|
|
52
|
-
|
|
53
|
-
# pipenv
|
|
54
|
-
pipenv install --dev decoy
|
|
55
47
|
```
|
|
56
48
|
|
|
57
49
|
## Setup
|
|
@@ -171,4 +163,3 @@ See [spying with verify][] for more details.
|
|
|
171
163
|
[creating mocks]: https://michael.cousins.io/decoy/usage/create/
|
|
172
164
|
[stubbing with when]: https://michael.cousins.io/decoy/usage/when/
|
|
173
165
|
[spying with verify]: https://michael.cousins.io/decoy/usage/verify/
|
|
174
|
-
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<a title="Code Coverage" href="https://app.codecov.io/gh/mcous/decoy/"><img src="https://img.shields.io/codecov/c/github/mcous/decoy?style=flat-square"></a>
|
|
9
9
|
<a title="License" href="https://github.com/mcous/decoy/blob/main/LICENSE"><img src="https://img.shields.io/github/license/mcous/decoy?style=flat-square"></a>
|
|
10
10
|
<a title="PyPI Version"href="https://pypi.org/project/decoy/"><img src="https://img.shields.io/pypi/v/decoy?style=flat-square"></a>
|
|
11
|
-
<a title="Supported Python Versions" href="https://pypi.org/project/decoy/"><img src="https://img.shields.io/
|
|
11
|
+
<a title="Supported Python Versions" href="https://pypi.org/project/decoy/"><img src="https://img.shields.io/python/required-version-toml?style=flat-square&tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fmcous%2Fdecoy%2Fmain%2Fpyproject.toml"></a>
|
|
12
12
|
</p>
|
|
13
13
|
<p>
|
|
14
14
|
<a href="https://michael.cousins.io/decoy/" class="decoy-hidden">Usage guide and documentation</a>
|
|
@@ -22,14 +22,7 @@ Decoy mocks are **async/await** and **type-checking** friendly. Decoy is heavily
|
|
|
22
22
|
## Install
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
# pip
|
|
26
25
|
pip install decoy
|
|
27
|
-
|
|
28
|
-
# poetry
|
|
29
|
-
poetry add --dev decoy
|
|
30
|
-
|
|
31
|
-
# pipenv
|
|
32
|
-
pipenv install --dev decoy
|
|
33
26
|
```
|
|
34
27
|
|
|
35
28
|
## Setup
|
|
@@ -28,17 +28,17 @@ See the [matchers guide][] for more details.
|
|
|
28
28
|
"""
|
|
29
29
|
|
|
30
30
|
from re import compile as compile_re
|
|
31
|
-
from typing import
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
from typing import (
|
|
32
|
+
Any,
|
|
33
|
+
Generic,
|
|
34
|
+
List,
|
|
35
|
+
Mapping,
|
|
36
|
+
Optional,
|
|
37
|
+
Pattern,
|
|
38
|
+
Type,
|
|
39
|
+
TypeVar,
|
|
40
|
+
cast,
|
|
41
|
+
)
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class _AnythingOrNone:
|
|
@@ -212,9 +212,9 @@ def HasAttributes(attributes: Mapping[str, Any]) -> Any:
|
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
class _DictMatching:
|
|
215
|
-
_values: Mapping[
|
|
215
|
+
_values: Mapping[Any, Any]
|
|
216
216
|
|
|
217
|
-
def __init__(self, values: Mapping[
|
|
217
|
+
def __init__(self, values: Mapping[Any, Any]) -> None:
|
|
218
218
|
self._values = values
|
|
219
219
|
|
|
220
220
|
def __eq__(self, target: object) -> bool:
|
|
@@ -235,7 +235,7 @@ class _DictMatching:
|
|
|
235
235
|
return f"<DictMatching {self._values!r}>"
|
|
236
236
|
|
|
237
237
|
|
|
238
|
-
def DictMatching(values: Mapping[
|
|
238
|
+
def DictMatching(values: Mapping[Any, Any]) -> Any:
|
|
239
239
|
"""Match any dictionary with the passed in keys / values.
|
|
240
240
|
|
|
241
241
|
Arguments:
|
|
@@ -362,12 +362,32 @@ def ErrorMatching(error: Type[ErrorT], match: Optional[str] = None) -> ErrorT:
|
|
|
362
362
|
return cast(ErrorT, _ErrorMatching(error, match))
|
|
363
363
|
|
|
364
364
|
|
|
365
|
-
|
|
365
|
+
CapturedT = TypeVar("CapturedT")
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class ValueCaptor(Generic[CapturedT]):
|
|
369
|
+
"""Match anything, capturing its value for further assertions.
|
|
370
|
+
|
|
371
|
+
Compare against the `matcher` property to capture a value.
|
|
372
|
+
The last captured value is available via `captor.value`,
|
|
373
|
+
while all captured values are stored in `captor.values`.
|
|
374
|
+
|
|
375
|
+
!!! example
|
|
376
|
+
```python
|
|
377
|
+
captor = ValueCaptor[str]()
|
|
378
|
+
assert "foobar" == captor.matcher
|
|
379
|
+
print(captor.value) # "foobar"
|
|
380
|
+
print(captor.values) # ["foobar"]
|
|
381
|
+
```
|
|
382
|
+
"""
|
|
383
|
+
|
|
384
|
+
_values: List[object]
|
|
385
|
+
|
|
366
386
|
def __init__(self) -> None:
|
|
367
|
-
self._values
|
|
387
|
+
self._values = []
|
|
368
388
|
|
|
369
389
|
def __eq__(self, target: object) -> bool:
|
|
370
|
-
"""
|
|
390
|
+
"""Captors are always "equal" to a given target."""
|
|
371
391
|
self._values.append(target)
|
|
372
392
|
return True
|
|
373
393
|
|
|
@@ -376,11 +396,19 @@ class _Captor:
|
|
|
376
396
|
return "<Captor>"
|
|
377
397
|
|
|
378
398
|
@property
|
|
379
|
-
def
|
|
380
|
-
"""
|
|
399
|
+
def matcher(self) -> CapturedT:
|
|
400
|
+
"""Match anything, capturing its value.
|
|
401
|
+
|
|
402
|
+
This method exists as a type-checking convenience.
|
|
403
|
+
"""
|
|
404
|
+
return cast(CapturedT, self)
|
|
405
|
+
|
|
406
|
+
@property
|
|
407
|
+
def value(self) -> object:
|
|
408
|
+
"""The latest captured value.
|
|
381
409
|
|
|
382
410
|
Raises:
|
|
383
|
-
AssertionError:
|
|
411
|
+
AssertionError: no value has been captured.
|
|
384
412
|
"""
|
|
385
413
|
if len(self._values) == 0:
|
|
386
414
|
raise AssertionError("No value captured by captor.")
|
|
@@ -388,24 +416,15 @@ class _Captor:
|
|
|
388
416
|
return self._values[-1]
|
|
389
417
|
|
|
390
418
|
@property
|
|
391
|
-
def values(self) -> List[
|
|
392
|
-
"""
|
|
419
|
+
def values(self) -> List[object]:
|
|
420
|
+
"""All captured values."""
|
|
393
421
|
return self._values
|
|
394
422
|
|
|
395
423
|
|
|
396
424
|
def Captor() -> Any:
|
|
397
|
-
"""Match anything, capturing its value.
|
|
425
|
+
"""Match anything, capturing its value for further assertions.
|
|
398
426
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
helpful if a captor needs to be triggered multiple times.
|
|
402
|
-
|
|
403
|
-
!!! example
|
|
404
|
-
```python
|
|
405
|
-
captor = Captor()
|
|
406
|
-
assert "foobar" == captor
|
|
407
|
-
print(captor.value) # "foobar"
|
|
408
|
-
print(captor.values) # ["foobar"]
|
|
409
|
-
```
|
|
427
|
+
!!! tip
|
|
428
|
+
Prefer [decoy.matchers.ValueCaptor][], which has better type annotations.
|
|
410
429
|
"""
|
|
411
|
-
return
|
|
430
|
+
return ValueCaptor()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "decoy"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.0"
|
|
4
4
|
description = "Opinionated mocking library for Python"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -29,39 +29,33 @@ Changelog = "https://github.com/mcous/decoy/releases"
|
|
|
29
29
|
|
|
30
30
|
[dependency-groups]
|
|
31
31
|
dev = [
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"pytest-mypy-plugins (==3.1.2) ; python_version >= '3.8' and python_version < '3.9'",
|
|
52
|
-
"pytest-mypy-plugins (==3.2.0) ; python_version >= '3.9'",
|
|
53
|
-
"pytest-xdist (==3.5.0) ; python_version < '3.8'",
|
|
54
|
-
"pytest-xdist (==3.6.1) ; python_version >= '3.8' and python_version < '3.9'",
|
|
55
|
-
"pytest-xdist (==3.7.0) ; python_version >= '3.9'",
|
|
56
|
-
"ruff (==0.14.7)"
|
|
57
|
-
]
|
|
58
|
-
|
|
59
|
-
docs = [
|
|
32
|
+
"coverage[toml] (==7.2.7) ; python_version < '3.8'",
|
|
33
|
+
"coverage[toml] (==7.6.1) ; python_version >= '3.8' and python_version < '3.9'",
|
|
34
|
+
"coverage[toml] (==7.9.1) ; python_version >= '3.9'",
|
|
35
|
+
"mypy (==1.4.1) ; python_version < '3.8'",
|
|
36
|
+
"mypy (==1.14.1) ; python_version >= '3.8' and python_version < '3.9'",
|
|
37
|
+
"mypy (==1.16.0) ; python_version >= '3.9'",
|
|
38
|
+
"pytest (==7.4.4) ; python_version < '3.8'",
|
|
39
|
+
"pytest (==8.3.5) ; python_version >= '3.8' and python_version < '3.9'",
|
|
40
|
+
"pytest (==8.4.0) ; python_version >= '3.9'",
|
|
41
|
+
"pytest-asyncio (==0.21.2) ; python_version < '3.8'",
|
|
42
|
+
"pytest-asyncio (==0.24.0) ; python_version >= '3.8' and python_version < '3.9'",
|
|
43
|
+
"pytest-asyncio (==1.0.0) ; python_version >= '3.9'",
|
|
44
|
+
"pytest-mypy-plugins (==2.0.0) ; python_version < '3.8'",
|
|
45
|
+
"pytest-mypy-plugins (==3.1.2) ; python_version >= '3.8' and python_version < '3.9'",
|
|
46
|
+
"pytest-mypy-plugins (==3.2.0) ; python_version >= '3.9'",
|
|
47
|
+
"pytest-xdist (==3.5.0) ; python_version < '3.8'",
|
|
48
|
+
"pytest-xdist (==3.6.1) ; python_version >= '3.8' and python_version < '3.9'",
|
|
49
|
+
"pytest-xdist (==3.7.0) ; python_version >= '3.9'",
|
|
50
|
+
"ruff (==0.14.10)",
|
|
60
51
|
"mkdocs (==1.6.1) ; python_version >= '3.10'",
|
|
61
|
-
"mkdocs-material (==9.
|
|
62
|
-
"mkdocstrings[python] (==0.
|
|
52
|
+
"mkdocs-material (==9.7.1) ; python_version >= '3.10'",
|
|
53
|
+
"mkdocstrings[python] (==1.0.0) ; python_version >= '3.10'"
|
|
63
54
|
]
|
|
64
55
|
|
|
56
|
+
[tool.poe]
|
|
57
|
+
executor.type = "uv"
|
|
58
|
+
|
|
65
59
|
[tool.poe.tasks]
|
|
66
60
|
all = [
|
|
67
61
|
"check",
|
|
@@ -82,7 +76,7 @@ coverage = "coverage report"
|
|
|
82
76
|
coverage-xml = "coverage xml"
|
|
83
77
|
docs = "mkdocs serve"
|
|
84
78
|
build-docs = "mkdocs build"
|
|
85
|
-
build-package = "
|
|
79
|
+
build-package = "uv build"
|
|
86
80
|
check-ci = ["check", "lint", "format-check"]
|
|
87
81
|
test-ci = ["test-once", "coverage-xml"]
|
|
88
82
|
|
|
@@ -111,5 +105,12 @@ ignore = ["ANN401", "D107", "E501"]
|
|
|
111
105
|
convention = "google"
|
|
112
106
|
|
|
113
107
|
[build-system]
|
|
114
|
-
requires = ["
|
|
115
|
-
build-backend = "
|
|
108
|
+
requires = ["uv_build>=0.9.21,<0.10.0"]
|
|
109
|
+
build-backend = "uv_build"
|
|
110
|
+
|
|
111
|
+
[tool.uv.build-backend]
|
|
112
|
+
module-name = "decoy"
|
|
113
|
+
module-root = ""
|
|
114
|
+
|
|
115
|
+
[tool.uv]
|
|
116
|
+
required-version = ">=0.9.21,<0.10.0"
|
decoy-2.2.1/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020-2023, Michael Cousins
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|