pytest-quint-connect 0.1.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.
- pytest_quint_connect-0.1.0/.gitignore +22 -0
- pytest_quint_connect-0.1.0/CHANGELOG.md +16 -0
- pytest_quint_connect-0.1.0/LICENSE +202 -0
- pytest_quint_connect-0.1.0/PKG-INFO +229 -0
- pytest_quint_connect-0.1.0/PROVENANCE.md +45 -0
- pytest_quint_connect-0.1.0/README.md +202 -0
- pytest_quint_connect-0.1.0/docs/ci-toolkit.md +65 -0
- pytest_quint_connect-0.1.0/docs/drivers.md +118 -0
- pytest_quint_connect-0.1.0/docs/limits.md +34 -0
- pytest_quint_connect-0.1.0/docs/manifest.md +49 -0
- pytest_quint_connect-0.1.0/docs/reference.md +72 -0
- pytest_quint_connect-0.1.0/dogfood/README.md +38 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/README.md +19 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/conftest.py +66 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/lru.qnt +61 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/lru_cache.py +68 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/lru_cache_driver.py +73 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/pytest.ini +4 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/quint-connect.json +22 -0
- pytest_quint_connect-0.1.0/examples/lru_cache/test_lru_contract.py +7 -0
- pytest_quint_connect-0.1.0/pyproject.toml +65 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/__init__.py +61 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/cli.py +64 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/codegen.py +391 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/compare.py +195 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/contract.py +284 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/itf.py +295 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/plugin.py +471 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/py.typed +0 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/quint.py +244 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/replay.py +301 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/toolchain/package-lock.json +802 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/toolchain/package.json +9 -0
- pytest_quint_connect-0.1.0/src/pytest_quint_connect/typed.py +105 -0
- pytest_quint_connect-0.1.0/tests/.gv-dependencies.yaml +34 -0
- pytest_quint_connect-0.1.0/tests/data/lru/sample-5.itf.json +1 -0
- pytest_quint_connect-0.1.0/tests/data/lru/witness-evicts.itf.json +1 -0
- pytest_quint_connect-0.1.0/tests/data/mbt/probe-mbt.itf.json +1 -0
- pytest_quint_connect-0.1.0/tests/data/mbt/probe.qnt +33 -0
- pytest_quint_connect-0.1.0/tests/data/session/sample-0.itf.json +1 -0
- pytest_quint_connect-0.1.0/tests/lru_support.py +26 -0
- pytest_quint_connect-0.1.0/tests/test_codegen.py +289 -0
- pytest_quint_connect-0.1.0/tests/test_compare.py +72 -0
- pytest_quint_connect-0.1.0/tests/test_contract.py +72 -0
- pytest_quint_connect-0.1.0/tests/test_itf.py +163 -0
- pytest_quint_connect-0.1.0/tests/test_plugin.py +243 -0
- pytest_quint_connect-0.1.0/tests/test_release.py +34 -0
- pytest_quint_connect-0.1.0/tests/test_replay.py +151 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.venv*/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.ruff_cache/
|
|
6
|
+
.test-impact/
|
|
7
|
+
impact-audit/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.coverage
|
|
11
|
+
coverage.xml
|
|
12
|
+
htmlcov/
|
|
13
|
+
tutorial-report.json
|
|
14
|
+
|
|
15
|
+
# Built documentation
|
|
16
|
+
/site/
|
|
17
|
+
/.venv-docs/
|
|
18
|
+
|
|
19
|
+
# Local judge credentials
|
|
20
|
+
.env
|
|
21
|
+
.artifacts/
|
|
22
|
+
.impact-audit/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-11-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **codegen:** generate typed driver bases from the Quint model ([#2](https://github.com/gigaverse-app/pytest-quint-connect/issues/2)) ([156a334](https://github.com/gigaverse-app/pytest-quint-connect/commit/156a334c8c9996f6f0acb6bc806788b9de6162d0))
|
|
9
|
+
* replay Quint-generated histories against Python implementations under pytest ([7db6585](https://github.com/gigaverse-app/pytest-quint-connect/commit/7db65854a1f0ae4c5c4ad5503297d624cf2d3163))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug fixes
|
|
13
|
+
|
|
14
|
+
* **replay:** accept unbranched steps in the mbt cross-check, found by dogfooding ([#3](https://github.com/gigaverse-app/pytest-quint-connect/issues/3)) ([4892ec6](https://github.com/gigaverse-app/pytest-quint-connect/commit/4892ec6ac39ae44fcc8f15c5812c50f5338e1565))
|
|
15
|
+
|
|
16
|
+
## Changelog
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pytest-quint-connect
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model-based testing for Python: replay Quint-generated histories against real implementations under pytest
|
|
5
|
+
Project-URL: Homepage, https://github.com/gigaverse-app/pytest-quint-connect
|
|
6
|
+
Project-URL: Repository, https://github.com/gigaverse-app/pytest-quint-connect
|
|
7
|
+
Project-URL: Issues, https://github.com/gigaverse-app/pytest-quint-connect/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/gigaverse-app/pytest-quint-connect/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Gigaverse
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: formal-methods,itf,model-based-testing,pytest,quint,specification,testing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Framework :: Pytest
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: pytest>=8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# pytest-quint-connect
|
|
29
|
+
|
|
30
|
+
[](https://github.com/gigaverse-app/pytest-quint-connect/actions/workflows/ci.yml)
|
|
31
|
+
[](pyproject.toml)
|
|
32
|
+
[](https://quint.sh)
|
|
33
|
+
[](src/pytest_quint_connect/py.typed)
|
|
34
|
+
[](LICENSE)
|
|
35
|
+
[](skills/pytest-quint-connect/SKILL.md)
|
|
36
|
+
|
|
37
|
+
**Model-based testing for Python under pytest.** [Quint](https://quint.sh)
|
|
38
|
+
generates histories from your specification; pytest-quint-connect replays every
|
|
39
|
+
step against your real Python implementation and compares the state you read back
|
|
40
|
+
with the state the model expects.
|
|
41
|
+
|
|
42
|
+
This is a community Python integration in the spirit of
|
|
43
|
+
[Quint Connect](https://github.com/quint-co/quint-connect) (Rust) and
|
|
44
|
+
[Quint's model-based testing guide](https://quint.sh/docs/model-based-testing).
|
|
45
|
+
It is not an official Quint project and is not endorsed by its maintainers.
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
test_lru_contract.py::test_lru_cache[witness-evictsLeastRecentlyUsedTest] FAILED
|
|
49
|
+
|
|
50
|
+
Quint contract 'lru-cache': implementation state differs from the model
|
|
51
|
+
trace: .artifacts/quint-connect/lru-cache/witness-evictsLeastRecentlyUsedTest-0.itf.json
|
|
52
|
+
state: 3 after action fetch(key='a', value=0)
|
|
53
|
+
seed: 7
|
|
54
|
+
4 difference(s):
|
|
55
|
+
entries[0].key: values differ
|
|
56
|
+
expected: 'b'
|
|
57
|
+
actual: 'a'
|
|
58
|
+
...
|
|
59
|
+
reproduce: pytest test_lru_contract.py::test_lru_cache --quint-replay .artifacts/quint-connect/lru-cache/witness-evictsLeastRecentlyUsedTest-0.itf.json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
Install the plugin, plus Node.js 22+ with npm. On first use the plugin installs its
|
|
65
|
+
locked Quint 0.33.1 into a per-user cache. To use your own Quint, pass `--quint PATH`
|
|
66
|
+
or set `QUINT`.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install "pytest-quint-connect @ git+https://github.com/gigaverse-app/pytest-quint-connect"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Generate a typed driver base from the model, then declare the contract:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pytest-quint-connect codegen quint-connect.json -o lru_cache_driver.py
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# test_cache_contract.py
|
|
80
|
+
from pytest_quint_connect import quint_contract
|
|
81
|
+
|
|
82
|
+
test_cache = quint_contract("quint-connect.json", driver="cache_driver")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Subclass the generated base. It has one typed method per model action and an
|
|
86
|
+
`observe()` typed as the model's observed state, so a type checker flags a driver
|
|
87
|
+
that has drifted from the spec:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
# conftest.py
|
|
91
|
+
import pytest
|
|
92
|
+
from lru_cache_driver import LruCacheDriver, Read, View # generated
|
|
93
|
+
from my_cache import LRUCache
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class CacheDriver(LruCacheDriver):
|
|
97
|
+
def __init__(self) -> None:
|
|
98
|
+
self.cache, self.last = LRUCache(2), {"tag": "NoRead"}
|
|
99
|
+
|
|
100
|
+
def init(self) -> None: ...
|
|
101
|
+
def inspect(self) -> None: ...
|
|
102
|
+
|
|
103
|
+
def store(self, key: str, value: int) -> None: # apply one model action to the real code
|
|
104
|
+
self.cache.put(key, value)
|
|
105
|
+
|
|
106
|
+
def fetch(self, key: str) -> None:
|
|
107
|
+
value = self.cache.get(key)
|
|
108
|
+
self.last: Read = {"tag": "Miss"} if value is None else {"tag": "Hit", "value": value}
|
|
109
|
+
|
|
110
|
+
def observe(self) -> View: # read the real state back
|
|
111
|
+
return {"entries": [{"key": k, "value": v} for k, v in self.cache.items()], "lastRead": self.last}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@pytest.fixture
|
|
115
|
+
def cache_driver():
|
|
116
|
+
return lambda context: CacheDriver() # called once per history: fresh state each time
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pytest --quint-require-complete
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
A hand-written driver that implements `step(step)` and `observe()` works too; see
|
|
124
|
+
[drivers](docs/drivers.md).
|
|
125
|
+
|
|
126
|
+
[examples/lru_cache](examples/lru_cache) is the complete version. It checks a
|
|
127
|
+
list-based cache and an `OrderedDict` refactor against the same generated
|
|
128
|
+
histories, catches a cache whose reads forget to refresh recency, and runs from
|
|
129
|
+
the installed wheel in CI.
|
|
130
|
+
|
|
131
|
+
## What a contract run does
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
quint-connect.json ──► quint typecheck ──► quint test (named witnesses) ──► witness-*.itf.json ─┐
|
|
135
|
+
└──► quint run --mbt (seeded samples) ──► sample-*.itf.json ─┤
|
|
136
|
+
▼
|
|
137
|
+
pytest: test_x[witness-…] test_x[sample-N] ──► fresh driver per history ──► step → observe → compare
|
|
138
|
+
test_x[mutant-…] every trace through the mutant; only an observed mismatch counts
|
|
139
|
+
test_x[coverage] every declared action reached
|
|
140
|
+
▼
|
|
141
|
+
.artifacts/quint-connect/results.json, traces, logs, mismatch-*.json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- **Real pytest cases.** Each witness, sample, mutant and the coverage check is a
|
|
145
|
+
parametrized case: selectable with `-k`, listed by `--collect-only`, reported in
|
|
146
|
+
JUnit (with `quint_trace`, `quint_seed` and `quint_detected_by` properties),
|
|
147
|
+
with ordinary fixture setup and teardown.
|
|
148
|
+
- **Fresh Quint, every run.** Traces are regenerated from the model with the
|
|
149
|
+
manifest's seed and bounds; the output directory is emptied first. Collection
|
|
150
|
+
never runs Quint; a Quint failure is a setup error for every case of that contract.
|
|
151
|
+
- **Mutation controls.** A mutant passes only when some generated history produces
|
|
152
|
+
an observed-state mismatch. An exception while building or running the mutant fails
|
|
153
|
+
the case: it is not detection.
|
|
154
|
+
- **Complete or not.** With `--quint-require-complete`, the session fails unless every
|
|
155
|
+
contract in `quint_required_contracts` ran every case and passed. A `-k`-filtered run
|
|
156
|
+
is recorded as `partial`, a replay as `replay-only`; a crash leaves `running`, never
|
|
157
|
+
an earlier `passed`.
|
|
158
|
+
- **Actionable failures.** A mismatch names the trace, state, action and arguments,
|
|
159
|
+
a field-level expected/actual difference, the seed and a command that replays that
|
|
160
|
+
exact trace (`--quint-replay`, optionally `--quint-mutant`).
|
|
161
|
+
|
|
162
|
+
## To / Read
|
|
163
|
+
|
|
164
|
+
| To | Read |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| Set it up with an agent | [skills/pytest-quint-connect/SKILL.md](skills/pytest-quint-connect/SKILL.md) |
|
|
167
|
+
| Write a manifest | [docs/manifest.md](docs/manifest.md) |
|
|
168
|
+
| Write a driver and choose a step convention | [docs/drivers.md](docs/drivers.md) |
|
|
169
|
+
| Know what a passing run does and does not prove | [docs/limits.md](docs/limits.md) |
|
|
170
|
+
| Configure options and read the receipt | [docs/reference.md](docs/reference.md) |
|
|
171
|
+
| See it on a production integration | [pytest-obligation's report-merge contract](https://github.com/gigaverse-app/pytest-obligation/tree/main/docs/quint/report-merge) |
|
|
172
|
+
|
|
173
|
+
## Measured
|
|
174
|
+
|
|
175
|
+
| Contract | Histories | Cases | Mutants detected | Notes |
|
|
176
|
+
| --- | --- | --- | --- | --- |
|
|
177
|
+
| [LRU cache example](examples/lru_cache) | 15 (3 witnesses, 12 samples) | 17 per implementation | 1/1 | list and `OrderedDict` implementations pass; the stale-read cache fails 4 of 15 histories |
|
|
178
|
+
| pytest-obligation `merge_reports` | 21 (5 witnesses, 16 samples) | 28 | 6/6 | same 21 histories, state for state, as the runner it replaced |
|
|
179
|
+
| [This plugin's own receipts](dogfood) | 8 (4 witnesses, 4 samples) | 13 | 4/4 | each step is a real pytest session; the mutants break the plugin's completeness and receipt logic |
|
|
180
|
+
|
|
181
|
+
Quint 0.33.1, TypeScript backend. See [PROVENANCE.md](PROVENANCE.md) for where the
|
|
182
|
+
engine came from and how the baseline was reproduced.
|
|
183
|
+
|
|
184
|
+
### Duplicates kept out
|
|
185
|
+
|
|
186
|
+
Local hooks and the required PR check prevent new copies. The weekly audit
|
|
187
|
+
records progress against the accepted backlog. [Setup and cleanup workflow](CONTRIBUTING.md#duplication).
|
|
188
|
+
|
|
189
|
+
<!-- dry-lint-progress:start -->
|
|
190
|
+
<a href="https://github.com/gigaverse-app/dry-lint"><picture><source media="(prefers-color-scheme: dark)" srcset="https://dry-lint-counter.gigaverse-oss.workers.dev/v1/sign.svg?theme=dark&key=bc47fb5de1a72359c95c190667ac9a84218d2ce822909a59d7e114ff2779542f&name=gigaverse-app%2Fpytest-quint-connect&cleaned=0&remaining=5&dismissed=0"><img alt="dry-lint in gigaverse-app/pytest-quint-connect: new duplicates kept out of its pull requests, 0 old duplicates cleaned up, 5 remaining" src="https://dry-lint-counter.gigaverse-oss.workers.dev/v1/sign.svg?key=bc47fb5de1a72359c95c190667ac9a84218d2ce822909a59d7e114ff2779542f&name=gigaverse-app%2Fpytest-quint-connect&cleaned=0&remaining=5&dismissed=0" width="100%"></picture></a>
|
|
191
|
+
|
|
192
|
+
**Reviewed duplication debt** · Counts from the committed baselines.
|
|
193
|
+
|
|
194
|
+
| Accepted pairs | Remaining | Retired | Dismissed |
|
|
195
|
+
| :-- | --: | --: | --: |
|
|
196
|
+
| Functions | 5 | 0 | 0 |
|
|
197
|
+
| Models | Not initialized | — | — |
|
|
198
|
+
|
|
199
|
+
[Accepted backlog](.dry-lint/baseline.json) · [Weekly audit](https://github.com/gigaverse-app/pytest-quint-connect/actions/workflows/dry-lint-audit.yml)
|
|
200
|
+
|
|
201
|
+
Retired means a side was removed, or (functions only) the judge now finds the pair separate. It is not a count of refactors. Dismissals stay separate; an uninitialized model baseline is unknown.
|
|
202
|
+
<!-- dry-lint-progress:end -->
|
|
203
|
+
|
|
204
|
+
## Related projects
|
|
205
|
+
|
|
206
|
+
| Project | What it does |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| [pytest-obligation](https://github.com/gigaverse-app/pytest-obligation) | Conformance proofs for background work that must survive lost messages and dead workers |
|
|
209
|
+
| [Due](https://github.com/gigaverse-app/due) | Durable obligations for Python: PostgreSQL remembers what is owed |
|
|
210
|
+
| [pytest-selective](https://github.com/gigaverse-app/pytest-selective) | Explainable test impact analysis for pytest |
|
|
211
|
+
| [CI-esta](https://github.com/gigaverse-app/ci-esta) | CI observability and honest merge gates |
|
|
212
|
+
| [dry-lint](https://github.com/gigaverse-app/dry-lint) | Finds code that re-implements what the codebase already does |
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
Apache 2.0. See [CONTRIBUTING.md](CONTRIBUTING.md) to work on pytest-quint-connect
|
|
217
|
+
itself and [RELEASING.md](RELEASING.md) for publishing.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
[](https://github.com/gigaverse-app/ci-esta)
|
|
222
|
+
|
|
223
|
+
[](https://github.com/gigaverse-app/pytest-selective)
|
|
224
|
+
|
|
225
|
+
<sub>Pull requests run only the [test lanes](.github/test-lanes.json) and test files a
|
|
226
|
+
change can affect, chosen by [pytest-selective](https://github.com/gigaverse-app/pytest-selective).
|
|
227
|
+
[CI-esta](https://github.com/gigaverse-app/ci-esta) reports this repository's CI timing,
|
|
228
|
+
keeps its test durations and owns its required gate. Neither is a dependency of
|
|
229
|
+
pytest-quint-connect. See [how CI runs here](docs/ci-toolkit.md).</sub>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Provenance
|
|
2
|
+
|
|
3
|
+
pytest-quint-connect was extracted from two working, application-specific Quint
|
|
4
|
+
replay runners at Gigaverse, with authorization to open-source them:
|
|
5
|
+
|
|
6
|
+
| Source | Commit | Files |
|
|
7
|
+
| --- | --- | --- |
|
|
8
|
+
| [pytest-obligation](https://github.com/gigaverse-app/pytest-obligation) | `6c923bff2c7fd1220cb837d14fbbf565e1b5c0e5` | `scripts/quint/replay.py`, `scripts/quint/test_replay.py`, `scripts/quint/README.md`, `scripts/quint/package.json`, `scripts/quint/package-lock.json`, `docs/quint/report-merge/` |
|
|
9
|
+
| [Due](https://github.com/gigaverse-app/due) | `3709d585ffc6dd391e823e81d8000304f3ff906f` | `scripts/ci/check_quint_report.py`, `docs/quint/report-provenance/` |
|
|
10
|
+
|
|
11
|
+
Both sources are Apache-2.0 projects of the same copyright holder.
|
|
12
|
+
|
|
13
|
+
## What changed in the extraction
|
|
14
|
+
|
|
15
|
+
- The generation, ITF decoding and replay engine is separated from pytest and has no
|
|
16
|
+
knowledge of either source repository: their hardcoded repository layout,
|
|
17
|
+
`pytest_obligation` import check, `docs/quint` discovery and source-mutation helper
|
|
18
|
+
became manifest fields (`root`, `attest`, `sources`) and consumer-owned driver code.
|
|
19
|
+
- The single opaque runner became pytest cases: one per witness, sampled history,
|
|
20
|
+
mutant and action-coverage check, with fixtures, JUnit, selection and saved-trace replay.
|
|
21
|
+
- The ITF decoder was rewritten. The original stringified map keys and decoded sets
|
|
22
|
+
to sorted lists, which is correct only for its one contract. The new decoder keeps
|
|
23
|
+
every Quint type distinct. [itf-py](https://github.com/konnov/itf-py) 0.5.0 was
|
|
24
|
+
evaluated and not used: it decodes records to namedtuples (so `{a: 1, b: 2}`,
|
|
25
|
+
`{b: 1, a: 2}` and the tuple `(1, 2)` compare equal), and it raises on every Quint
|
|
26
|
+
0.33.1 trace that contains a unit variant (`{"#tup": []}` is not a valid field name).
|
|
27
|
+
- `--mbt` metadata is supported alongside the original explicit `event`/`observed`
|
|
28
|
+
convention, and cross-checked against it when both are present.
|
|
29
|
+
- Due's runner contributed the checks for required exit status and per-trace output
|
|
30
|
+
status. Its report-provenance contract replays a shell workflow and has not been
|
|
31
|
+
migrated.
|
|
32
|
+
|
|
33
|
+
## Baseline reproduction
|
|
34
|
+
|
|
35
|
+
On pytest-obligation `6c923bff`, with Quint 0.33.1 on Windows,
|
|
36
|
+
`python scripts/quint/replay.py --topic report-merge` passed **21 generated
|
|
37
|
+
histories** (5 witnesses, 16 samples) and **detected all six mutations**. The same
|
|
38
|
+
contract under pytest-quint-connect, from an installed wheel, generated the same 21
|
|
39
|
+
histories (every `event` and `observed` value identical, state for state), passed
|
|
40
|
+
all 28 cases and detected all six mutations. The original runner's negative
|
|
41
|
+
controls (altered observation, empty trace, missing generation, missing tool with a
|
|
42
|
+
stale success receipt, setup error during a mutant, edited historical model) are
|
|
43
|
+
covered by `tests/test_replay.py` and `tests/test_plugin.py`.
|
|
44
|
+
|
|
45
|
+
Copyright Gigaverse. Licensed under Apache-2.0; see [LICENSE](LICENSE).
|