pytest-extended-data 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,11 @@
1
+ """Pytest helpers for projects using Extended Data."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pytest_extended_data.plugin import assert_builtin_round_trip, assert_extended_shape
6
+
7
+
8
+ __all__ = [
9
+ "assert_builtin_round_trip",
10
+ "assert_extended_shape",
11
+ ]
@@ -0,0 +1,63 @@
1
+ """Pytest fixtures and assertions for Extended Data consumers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable, Mapping
6
+ from typing import TYPE_CHECKING, Any
7
+
8
+ import pytest
9
+
10
+
11
+ if TYPE_CHECKING:
12
+ from extended_data import ExtendedData
13
+
14
+
15
+ def _extended_data_type() -> type[ExtendedData]:
16
+ from extended_data import ExtendedData
17
+
18
+ return ExtendedData
19
+
20
+
21
+ def assert_extended_shape(value: ExtendedData, shape: str) -> None:
22
+ """Assert that an Extended Data value has the expected broad shape."""
23
+ extended_data = _extended_data_type()
24
+ if not isinstance(value, extended_data):
25
+ raise TypeError(f"expected ExtendedData value, got {type(value).__name__}")
26
+ assert value.shape == shape, f"expected ExtendedData shape {shape!r}, got {value.shape!r}"
27
+
28
+
29
+ def assert_builtin_round_trip(value: ExtendedData, expected: Any) -> None:
30
+ """Assert that an Extended Data value lowers to the expected built-in data."""
31
+ extended_data = _extended_data_type()
32
+ if not isinstance(value, extended_data):
33
+ raise TypeError(f"expected ExtendedData value, got {type(value).__name__}")
34
+
35
+ actual = value.as_builtin()
36
+ assert actual == expected, f"expected built-in data {expected!r}, got {actual!r}"
37
+
38
+ round_trip = extended_data(actual).as_builtin()
39
+ assert round_trip == expected, f"expected round-trip data {expected!r}, got {round_trip!r}"
40
+
41
+
42
+ @pytest.fixture
43
+ def extended_data_factory() -> Callable[[Any], ExtendedData]:
44
+ """Return the polymorphic Extended Data constructor."""
45
+ return _extended_data_type()
46
+
47
+
48
+ @pytest.fixture
49
+ def extended_data_payload() -> Mapping[str, Any]:
50
+ """Return a representative nested mapping payload."""
51
+ return {
52
+ "service": {
53
+ "name": "api",
54
+ "ports": [8080, 8443],
55
+ },
56
+ "enabled": True,
57
+ }
58
+
59
+
60
+ @pytest.fixture
61
+ def extended_data_value(extended_data_payload: Mapping[str, Any]) -> ExtendedData:
62
+ """Return the sample payload promoted to Extended Data."""
63
+ return _extended_data_type()(extended_data_payload)
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-extended-data
3
+ Version: 0.1.0
4
+ Summary: Pytest fixtures and assertions for projects using extended-data
5
+ Project-URL: Documentation, https://extended-data.dev
6
+ Project-URL: Issues, https://github.com/jbcom/extended-data/issues
7
+ Project-URL: Source, https://github.com/jbcom/extended-data
8
+ Project-URL: Changelog, https://github.com/jbcom/extended-data/blob/main/packages/pytest-extended-data/CHANGELOG.md
9
+ Author-email: Jon Bogaty <jon@jonbogaty.com>
10
+ Maintainer-email: Jon Bogaty <jon@jonbogaty.com>
11
+ License: MIT
12
+ Keywords: extended-data,fixtures,pytest,testing
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: extended-data>=8.3.1
25
+ Requires-Dist: pytest>=9.0.3
26
+ Description-Content-Type: text/markdown
27
+
28
+ # pytest-extended-data
29
+
30
+ `pytest-extended-data` publishes reusable pytest fixtures and assertions for
31
+ projects built on `extended-data`.
32
+
33
+ Install it in test environments:
34
+
35
+ ```bash
36
+ uv add --dev pytest-extended-data
37
+ ```
38
+
39
+ The plugin is exposed through the standard `pytest11` entry point. It provides:
40
+
41
+ - `extended_data_factory`: the `ExtendedData` polymorphic constructor.
42
+ - `extended_data_payload`: a small nested mapping payload for examples and smoke tests.
43
+ - `extended_data_value`: the payload wrapped as an `ExtendedData` value.
44
+ - `assert_extended_shape(value, shape)`: assertion helper for shape checks.
45
+ - `assert_builtin_round_trip(value, expected)`: assertion helper for export-boundary checks.
@@ -0,0 +1,7 @@
1
+ pytest_extended_data/__init__.py,sha256=6aK5aJ0Mr1o2-lbEHDD0cL3TAttqQa_HAtc59VX_Bn0,259
2
+ pytest_extended_data/plugin.py,sha256=NLXmABinOLARUC62EMxdosYzNZw_Ybdm1FBPODR49zM,2051
3
+ pytest_extended_data/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ pytest_extended_data-0.1.0.dist-info/METADATA,sha256=qjmssCzuwlazJLmY3nntnc_5BBz9CoyQBfnyowiz0yo,1869
5
+ pytest_extended_data-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
6
+ pytest_extended_data-0.1.0.dist-info/entry_points.txt,sha256=LsACoKN0f__vOwWv4BlChgo6OmaY9OeHZYb0t3Gw_60,55
7
+ pytest_extended_data-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [pytest11]
2
+ extended_data = pytest_extended_data.plugin