decoy 2.4.0__tar.gz → 2.5.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.
Files changed (38) hide show
  1. {decoy-2.4.0 → decoy-2.5.0}/PKG-INFO +1 -1
  2. decoy-2.5.0/decoy/pytest_plugin.py +58 -0
  3. {decoy-2.4.0 → decoy-2.5.0}/pyproject.toml +3 -1
  4. decoy-2.4.0/decoy/pytest_plugin.py +0 -33
  5. {decoy-2.4.0 → decoy-2.5.0}/README.md +0 -0
  6. {decoy-2.4.0 → decoy-2.5.0}/decoy/__init__.py +0 -0
  7. {decoy-2.4.0 → decoy-2.5.0}/decoy/call_handler.py +0 -0
  8. {decoy-2.4.0 → decoy-2.5.0}/decoy/context_managers.py +0 -0
  9. {decoy-2.4.0 → decoy-2.5.0}/decoy/core.py +0 -0
  10. {decoy-2.4.0 → decoy-2.5.0}/decoy/errors.py +0 -0
  11. {decoy-2.4.0 → decoy-2.5.0}/decoy/matchers.py +0 -0
  12. {decoy-2.4.0 → decoy-2.5.0}/decoy/mypy/__init__.py +0 -0
  13. {decoy-2.4.0 → decoy-2.5.0}/decoy/mypy/plugin.py +0 -0
  14. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/__init__.py +0 -0
  15. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/__init__.py +0 -0
  16. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/compare.py +0 -0
  17. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/decoy.py +0 -0
  18. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/errors.py +0 -0
  19. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/inspect.py +0 -0
  20. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/matcher.py +0 -0
  21. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/mock.py +0 -0
  22. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/state.py +0 -0
  23. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/stringify.py +0 -0
  24. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/values.py +0 -0
  25. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/verify.py +0 -0
  26. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/warnings.py +0 -0
  27. {decoy-2.4.0 → decoy-2.5.0}/decoy/next/_internal/when.py +0 -0
  28. {decoy-2.4.0 → decoy-2.5.0}/decoy/py.typed +0 -0
  29. {decoy-2.4.0 → decoy-2.5.0}/decoy/spy.py +0 -0
  30. {decoy-2.4.0 → decoy-2.5.0}/decoy/spy_core.py +0 -0
  31. {decoy-2.4.0 → decoy-2.5.0}/decoy/spy_events.py +0 -0
  32. {decoy-2.4.0 → decoy-2.5.0}/decoy/spy_log.py +0 -0
  33. {decoy-2.4.0 → decoy-2.5.0}/decoy/stringify.py +0 -0
  34. {decoy-2.4.0 → decoy-2.5.0}/decoy/stub_store.py +0 -0
  35. {decoy-2.4.0 → decoy-2.5.0}/decoy/types.py +0 -0
  36. {decoy-2.4.0 → decoy-2.5.0}/decoy/verifier.py +0 -0
  37. {decoy-2.4.0 → decoy-2.5.0}/decoy/warning_checker.py +0 -0
  38. {decoy-2.4.0 → decoy-2.5.0}/decoy/warnings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: decoy
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: Opinionated mocking library for Python
5
5
  Author: Michael Cousins
6
6
  Author-email: Michael Cousins <michael@cousins.io>>
@@ -0,0 +1,58 @@
1
+ """Pytest plugin to setup and teardown a Decoy instance.
2
+
3
+ The plugin will be registered with pytest when you install Decoy. It adds a
4
+ fixture without modifying any other pytest behavior. Its usage is optional
5
+ but highly recommended.
6
+ """
7
+
8
+ from typing import TYPE_CHECKING, Iterable, Union, get_type_hints
9
+
10
+ import pytest
11
+
12
+ from decoy import Decoy
13
+
14
+ if TYPE_CHECKING:
15
+ from decoy.next import Decoy as DecoyNext
16
+
17
+
18
+ @pytest.fixture()
19
+ def decoy(
20
+ request: pytest.FixtureRequest,
21
+ ) -> "Iterable[Union[Decoy, DecoyNext]]":
22
+ """Get a [decoy.Decoy][] container and [reset it][decoy.Decoy.reset] after the test.
23
+
24
+ This function is function-scoped [pytest fixture][] that will be
25
+ automatically inserted by the plugin.
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
+
32
+ [pytest fixture]: https://docs.pytest.org/en/latest/how-to/fixtures.html
33
+ [v3-preview]: ./v3/about.md
34
+
35
+ !!! example
36
+ ```python
37
+ def test_my_thing(decoy: Decoy) -> None:
38
+ my_fake_func = decoy.mock()
39
+ # ...
40
+ ```
41
+ """
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()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "decoy"
3
- version = "2.4.0"
3
+ version = "2.5.0"
4
4
  description = "Opinionated mocking library for Python"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -77,11 +77,13 @@ test = "pytest -f"
77
77
  test-once = "coverage run --branch --source=decoy -m pytest --mypy-same-process"
78
78
  coverage = "coverage report"
79
79
  coverage-xml = "coverage xml"
80
+ coverage-html = "coverage html"
80
81
  docs = "mkdocs serve --livereload"
81
82
  build-docs = "mkdocs build"
82
83
  build-package = "uv build"
83
84
  check-ci = ["check", "lint", "format-check"]
84
85
  test-ci = ["test-once", "coverage-xml"]
86
+ test-coverage = ["test-once", "coverage-html", "coverage"]
85
87
 
86
88
  [tool.pytest.ini_options]
87
89
  addopts = "--color=yes --mypy-ini-file=tests/legacy/typing/mypy.ini --mypy-only-local-stub"
@@ -1,33 +0,0 @@
1
- """Pytest plugin to setup and teardown a Decoy instance.
2
-
3
- The plugin will be registered with pytest when you install Decoy. It adds a
4
- fixture without modifying any other pytest behavior. Its usage is optional
5
- but highly recommended.
6
- """
7
-
8
- from typing import Iterable
9
-
10
- import pytest
11
-
12
- from decoy import Decoy
13
-
14
-
15
- @pytest.fixture()
16
- def decoy() -> Iterable[Decoy]:
17
- """Get a [decoy.Decoy][] container and [reset it][decoy.Decoy.reset] after the test.
18
-
19
- This function is function-scoped [pytest fixture][] that will be
20
- automatically inserted by the plugin.
21
-
22
- [pytest fixture]: https://docs.pytest.org/en/latest/how-to/fixtures.html
23
-
24
- !!! example
25
- ```python
26
- def test_my_thing(decoy: Decoy) -> None:
27
- my_fake_func = decoy.mock()
28
- # ...
29
- ```
30
- """
31
- decoy = Decoy()
32
- yield decoy
33
- decoy.reset()
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
File without changes
File without changes