pico-testing 0.1.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.
@@ -0,0 +1 @@
1
+ from .plugin import AUTO_PLUGINS_MARKER as AUTO_PLUGINS_MARKER
@@ -0,0 +1 @@
1
+ __version__ = '0.1.0'
pico_testing/plugin.py ADDED
@@ -0,0 +1,55 @@
1
+ """Pytest plugin: isolated pico containers by default.
2
+
3
+ Installed as a ``pytest11`` entry point — active in any venv that has
4
+ pico-testing, no conftest wiring needed.
5
+ """
6
+
7
+ import pytest
8
+
9
+ AUTO_PLUGINS_MARKER = "pico_auto_plugins"
10
+
11
+
12
+ def pytest_configure(config):
13
+ config.addinivalue_line(
14
+ "markers",
15
+ f"{AUTO_PLUGINS_MARKER}: allow pico-boot plugin auto-discovery in this test "
16
+ "(by default pico-testing sets PICO_BOOT_AUTO_PLUGINS=false)",
17
+ )
18
+
19
+
20
+ @pytest.fixture(autouse=True)
21
+ def pico_isolation(request, monkeypatch):
22
+ """Tests must not depend on which pico plugins happen to be installed
23
+ in the venv — auto-discovery is opt-in via the pico_auto_plugins marker."""
24
+ if request.node.get_closest_marker(AUTO_PLUGINS_MARKER) is None:
25
+ monkeypatch.setenv("PICO_BOOT_AUTO_PLUGINS", "false")
26
+
27
+
28
+ @pytest.fixture
29
+ def make_container():
30
+ """Factory for pico containers with automatic shutdown on teardown.
31
+
32
+ Usage::
33
+
34
+ def test_service(make_container):
35
+ container = make_container("my_pkg", config={"my": {"key": "value"}})
36
+ svc = container.get(MyService)
37
+ """
38
+ created = []
39
+
40
+ def _make(*modules, config=None, boot=False):
41
+ from pico_ioc import DictSource, configuration
42
+
43
+ if config is None or isinstance(config, dict):
44
+ config = configuration(DictSource(config or {}))
45
+ if boot:
46
+ from pico_boot import init
47
+ else:
48
+ from pico_ioc import init
49
+ container = init(modules=list(modules), config=config)
50
+ created.append(container)
51
+ return container
52
+
53
+ yield _make
54
+ for container in reversed(created):
55
+ container.shutdown()
pico_testing/py.typed ADDED
File without changes
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: pico-testing
3
+ Version: 0.1.0
4
+ Summary: Pytest plugin for the Pico ecosystem: isolated containers by default and a make_container fixture.
5
+ Author-email: David Perez Cabrera <dperezcabrera@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 David Pérez Cabrera
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/dperezcabrera/pico-testing
29
+ Project-URL: Documentation, https://dperezcabrera.github.io/pico-testing/
30
+ Project-URL: Repository, https://github.com/dperezcabrera/pico-testing
31
+ Project-URL: Changelog, https://github.com/dperezcabrera/pico-testing/blob/main/CHANGELOG.md
32
+ Project-URL: Issue Tracker, https://github.com/dperezcabrera/pico-testing/issues
33
+ Keywords: testing,pytest,fixtures,ioc,dependency injection,spring boot
34
+ Classifier: Development Status :: 4 - Beta
35
+ Classifier: Framework :: Pytest
36
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3 :: Only
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Programming Language :: Python :: 3.13
42
+ Classifier: Intended Audience :: Developers
43
+ Classifier: License :: OSI Approved :: MIT License
44
+ Classifier: Operating System :: OS Independent
45
+ Classifier: Typing :: Typed
46
+ Requires-Python: >=3.11
47
+ Description-Content-Type: text/markdown
48
+ License-File: LICENSE
49
+ Requires-Dist: pico-ioc>=2.2.0
50
+ Requires-Dist: pytest>=8
51
+ Provides-Extra: dev
52
+ Requires-Dist: pytest-asyncio; extra == "dev"
53
+ Requires-Dist: pytest-cov>=5; extra == "dev"
54
+ Requires-Dist: ruff; extra == "dev"
55
+ Requires-Dist: pico-boot>=0.1.0; extra == "dev"
56
+ Dynamic: license-file
57
+
58
+ # pico-testing
59
+
60
+ [![PyPI version](https://img.shields.io/pypi/v/pico-testing.svg)](https://pypi.org/project/pico-testing/)
61
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
62
+ [![CI](https://github.com/dperezcabrera/pico-testing/actions/workflows/ci.yml/badge.svg)](https://github.com/dperezcabrera/pico-testing/actions/workflows/ci.yml)
63
+ [![codecov](https://codecov.io/gh/dperezcabrera/pico-testing/branch/main/graph/badge.svg)](https://codecov.io/gh/dperezcabrera/pico-testing)
64
+ [![Docs](https://img.shields.io/badge/docs-mkdocs-blue)](https://dperezcabrera.github.io/pico-testing/)
65
+
66
+ Pytest plugin for the [pico ecosystem](https://github.com/dperezcabrera/pico-ioc): isolated containers by default and a `make_container` fixture with automatic shutdown.
67
+
68
+ ## Why
69
+
70
+ Any `pico_boot.init()` in a test auto-discovers every pico plugin installed in the venv — so a test suite passes or fails depending on what else happens to be installed. Every pico project ends up copying the same two conftest fixtures. This plugin ships them once:
71
+
72
+ - **Isolation by default**: `PICO_BOOT_AUTO_PLUGINS=false` is set for every test. Opt back in per-test with `@pytest.mark.pico_auto_plugins`.
73
+ - **`make_container`**: builds containers from explicit modules and config, and shuts them all down on teardown.
74
+
75
+ ## Installation
76
+
77
+ ```bash
78
+ pip install pico-testing
79
+ ```
80
+
81
+ No conftest wiring — installing it activates the plugin.
82
+
83
+ ## Quick start
84
+
85
+ ```python
86
+ import sys
87
+
88
+ def test_my_service(make_container):
89
+ container = make_container(
90
+ "my_package",
91
+ config={"my_prefix": {"key": "value"}},
92
+ )
93
+ service = container.get(MyService)
94
+ assert service.do_something() == "expected"
95
+ ```
96
+
97
+ `make_container(*modules, config=None, boot=False)`:
98
+
99
+ - `modules`: module objects or import strings, passed to `init(modules=[...])`.
100
+ - `config`: a plain dict (wrapped in `configuration(DictSource(...))`) or a ready `configuration(...)` object.
101
+ - `boot=True`: use `pico_boot.init` instead of `pico_ioc.init` (plugin auto-discovery still off unless the test is marked).
102
+
103
+ Re-enable plugin auto-discovery for a single test:
104
+
105
+ ```python
106
+ import pytest
107
+
108
+ @pytest.mark.pico_auto_plugins
109
+ def test_full_boot(make_container):
110
+ container = make_container(boot=True)
111
+ ```
112
+
113
+ ## Documentation
114
+
115
+ Full documentation: https://dperezcabrera.github.io/pico-testing/
116
+
117
+ ## License
118
+
119
+ MIT
@@ -0,0 +1,12 @@
1
+ pico_testing/__init__.py,sha256=C14pqnBELqlAZ5tN0POqpT83_4cQLWqb05524vHLBOI,63
2
+ pico_testing/_version.py,sha256=IMjkMO3twhQzluVTo8Z6rE7Eg-9U79_LGKMcsWLKBkY,22
3
+ pico_testing/plugin.py,sha256=vSbgXueEs63z3eyYS2JN88XzroZ8wQm3pEb4bsIOr3s,1692
4
+ pico_testing/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pico_testing-0.1.0.dist-info/licenses/LICENSE,sha256=N1_nOvHTM6BobYnOTNXiQkroDqCEi6EzfGBv8lWtyZ0,1077
6
+ pico_testing-0.1.0.dist-info/METADATA,sha256=2I1nswpAhbYWx9EJk3HJNrsuyfLHBT9odo_iTSgoXcQ,5267
7
+ pico_testing-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
8
+ pico_testing-0.1.0.dist-info/entry_points.txt,sha256=blnvNLQ9vWeTZnS3jvesXemggAIs-M_fn-tlenVuacQ,46
9
+ pico_testing-0.1.0.dist-info/scm_file_list.json,sha256=gkegZm4QUM-OaMylR6fhmdafTSgvm2DLMuubqlLR3ec,1001
10
+ pico_testing-0.1.0.dist-info/scm_version.json,sha256=gBMY4WkX0FZTEmS4trQBNaZj0SKmvLihS_JjPRVSlDY,160
11
+ pico_testing-0.1.0.dist-info/top_level.txt,sha256=OlSqE-jADkU2Pt5ROtsr5ONRYHFXHQaRvOcreVqtDK8,13
12
+ pico_testing-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [pytest11]
2
+ pico_testing = pico_testing.plugin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 David Pérez Cabrera
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.
@@ -0,0 +1,40 @@
1
+ {
2
+ "files": [
3
+ ".coveragerc",
4
+ "README.md",
5
+ "Makefile",
6
+ "tox.ini",
7
+ "LICENSE",
8
+ "pyproject.toml",
9
+ "SECURITY.md",
10
+ "mkdocs.yml",
11
+ "CHANGELOG.md",
12
+ "CONTRIBUTING.md",
13
+ "MANIFEST.in",
14
+ ".sonarcloud.properties",
15
+ "Dockerfile.test",
16
+ ".gitignore",
17
+ "CODE_OF_CONDUCT.md",
18
+ "docs/getting-started.md",
19
+ "docs/requirements.txt",
20
+ "docs/CHANGELOG.md",
21
+ "docs/faq.md",
22
+ "docs/index.md",
23
+ "docs/hooks.py",
24
+ "docs/stylesheets/extra.css",
25
+ "docs/javascripts/extra.js",
26
+ "src/pico_testing/py.typed",
27
+ "src/pico_testing/__init__.py",
28
+ "src/pico_testing/plugin.py",
29
+ "tests/test_plugin.py",
30
+ "tests/conftest.py",
31
+ ".github/PULL_REQUEST_TEMPLATE.md",
32
+ ".github/dependabot.yml",
33
+ ".github/ISSUE_TEMPLATE/bug_report.yml",
34
+ ".github/ISSUE_TEMPLATE/feature_request.yml",
35
+ ".github/workflows/docs.yml",
36
+ ".github/workflows/codeql.yml",
37
+ ".github/workflows/ci.yml",
38
+ ".github/workflows/publish-to-pypi.yml"
39
+ ]
40
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.1.0",
3
+ "distance": 0,
4
+ "node": "g68689a55b7a0f2ffc44269262159e386fb3c06de",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-07-10"
8
+ }
@@ -0,0 +1 @@
1
+ pico_testing