pact-python-cli 2.4.26.2__tar.gz → 2.5.7.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.
- pact_python_cli-2.5.7.0/PKG-INFO +151 -0
- pact_python_cli-2.5.7.0/README.md +119 -0
- {pact_python_cli-2.4.26.2 → pact_python_cli-2.5.7.0}/hatch_build.py +99 -52
- {pact_python_cli-2.4.26.2/src → pact_python_cli-2.5.7.0}/pact_cli/__init__.py +81 -8
- pact_python_cli-2.5.7.0/pact_cli/__version__.py +6 -0
- {pact_python_cli-2.4.26.2 → pact_python_cli-2.5.7.0}/pyproject.toml +61 -62
- pact_python_cli-2.4.26.2/PKG-INFO +0 -41
- pact_python_cli-2.4.26.2/README.md +0 -32
- pact_python_cli-2.4.26.2/cliff.toml +0 -113
- pact_python_cli-2.4.26.2/src/pact_cli/__version__.py +0 -21
- pact_python_cli-2.4.26.2/tests/.ruff.toml +0 -10
- pact_python_cli-2.4.26.2/tests/test_init.py +0 -175
- {pact_python_cli-2.4.26.2 → pact_python_cli-2.5.7.0}/.gitignore +0 -0
- {pact_python_cli-2.4.26.2 → pact_python_cli-2.5.7.0}/LICENSE +0 -0
- {pact_python_cli-2.4.26.2/src → pact_python_cli-2.5.7.0}/pact_cli/.gitkeep +0 -0
- {pact_python_cli-2.4.26.2/src → pact_python_cli-2.5.7.0}/pact_cli/py.typed +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pact-python-cli
|
|
3
|
+
Version: 2.5.7.0
|
|
4
|
+
Summary: Pact CLI bundle for Python
|
|
5
|
+
Project-URL: Bug Tracker, https://github.com/pact-foundation/pact-python/issues
|
|
6
|
+
Project-URL: Changelog, https://github.com/pact-foundation/pact-python/blob/main/pact-python-cli/CHANGELOG.md
|
|
7
|
+
Project-URL: Documentation, https://docs.pact.io
|
|
8
|
+
Project-URL: Homepage, https://pact.io
|
|
9
|
+
Project-URL: Repository, https://github.com/pact-foundation/pact-python
|
|
10
|
+
Author-email: Joshua Ellis <josh@jpellis.me>
|
|
11
|
+
Maintainer-email: Joshua Ellis <josh@jpellis.me>
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: cli,contract-testing,pact,pact-python
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
20
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
21
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
29
|
+
Classifier: Topic :: Software Development :: Testing
|
|
30
|
+
Requires-Python: >=3.10
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Pact Python CLI
|
|
35
|
+
|
|
36
|
+
> [!NOTE]
|
|
37
|
+
>
|
|
38
|
+
> This package is used to package and bundle the Pact CLI _only_. It does not provide any Python functionality or API.
|
|
39
|
+
|
|
40
|
+
<!-- markdownlint-disable no-inline-html -->
|
|
41
|
+
<div align="center"><table>
|
|
42
|
+
<tr>
|
|
43
|
+
<td>Package</td>
|
|
44
|
+
<td>
|
|
45
|
+
<a href="https://pypi.python.org/pypi/pact-python-cli"><img src="https://img.shields.io/pypi/v/pact-python-cli.svg" alt="Version"></a>
|
|
46
|
+
<a href="https://pypi.python.org/pypi/pact-python-cli"><img src="https://img.shields.io/pypi/pyversions/pact-python-cli.svg" alt="Python Versions"></a>
|
|
47
|
+
<a href="https://pypi.python.org/pypi/pact-python-cli"><img src="https://img.shields.io/pypi/dm/pact-python-cli.svg" alt="Downloads"></a>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
<tr>
|
|
51
|
+
<td>CI/CD</td>
|
|
52
|
+
<td>
|
|
53
|
+
<a
|
|
54
|
+
href="https://github.com/pact-foundation/pact-python/actions/workflows/test.yml?query=branch:main"><img
|
|
55
|
+
src="https://img.shields.io/github/actions/workflow/status/pact-foundation/pact-python/test.yml?branch=main&label=test"
|
|
56
|
+
alt="Test Status"></a>
|
|
57
|
+
<a
|
|
58
|
+
href="https://github.com/pact-foundation/pact-python/actions/workflows/build-cli.yml?query=branch:main"><img
|
|
59
|
+
src="https://img.shields.io/github/actions/workflow/status/pact-foundation/pact-python/build-cli.yml?branch=main&label=build"
|
|
60
|
+
alt="Build Status"></a>
|
|
61
|
+
<a
|
|
62
|
+
href="https://github.com/pact-foundation/pact-python/actions/workflows/docs.yml?query=branch:main"><img
|
|
63
|
+
src="https://img.shields.io/github/actions/workflow/status/pact-foundation/pact-python/docs.yml?branch=main&label=docs"
|
|
64
|
+
alt="Build Status"></a>
|
|
65
|
+
</td>
|
|
66
|
+
</tr>
|
|
67
|
+
<tr>
|
|
68
|
+
<td>Meta</td>
|
|
69
|
+
<td>
|
|
70
|
+
<a
|
|
71
|
+
href="https://github.com/pypa/hatch"><img
|
|
72
|
+
src="https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg"
|
|
73
|
+
alt="Hatch project"></a>
|
|
74
|
+
<a href="https://github.com/astral-sh/ruff"><img
|
|
75
|
+
src="https://img.shields.io/badge/ruff-ruff?label=linting&color=%23261230"
|
|
76
|
+
alt="linting - Ruff"></a>
|
|
77
|
+
<a href="https://github.com/astral-sh/ruff"><img
|
|
78
|
+
src="https://img.shields.io/badge/ruff-ruff?label=style&color=%23261230"
|
|
79
|
+
alt="style - Ruff"></a>
|
|
80
|
+
<a
|
|
81
|
+
href="https://github.com/python/mypy"><img
|
|
82
|
+
src="https://img.shields.io/badge/types-Mypy-blue.svg"
|
|
83
|
+
alt="types - Mypy"></a>
|
|
84
|
+
<a
|
|
85
|
+
href="https://pypi.python.org/pypi/pact-python-cli"><img
|
|
86
|
+
src="https://img.shields.io/pypi/l/pact-python-cli.svg"
|
|
87
|
+
alt="License"></a>
|
|
88
|
+
</td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td>Community</td>
|
|
92
|
+
<td>
|
|
93
|
+
<a
|
|
94
|
+
href="https://github.com/pact-foundation/pact-python/issues"><img
|
|
95
|
+
src="https://img.shields.io/github/issues/pact-foundation/pact-python.svg"
|
|
96
|
+
alt="Issues"></a>
|
|
97
|
+
<a
|
|
98
|
+
href="https://github.com/pact-foundation/pact-python/discussions"><img
|
|
99
|
+
src="https://img.shields.io/github/discussions/pact-foundation/pact-python.svg"
|
|
100
|
+
alt="Discussions"></a>
|
|
101
|
+
<a
|
|
102
|
+
href="https://github.com/pact-foundation/pact-python"><img
|
|
103
|
+
src="https://img.shields.io/github/stars/pact-foundation/pact-python.svg?style=flat"
|
|
104
|
+
alt="GitHub Stars"></a>
|
|
105
|
+
<br/>
|
|
106
|
+
<a
|
|
107
|
+
href="http://slack.pact.io"><img
|
|
108
|
+
src="https://img.shields.io/badge/slack-pact--foundation-4A154B.svg"
|
|
109
|
+
alt="Slack"></a>
|
|
110
|
+
<a
|
|
111
|
+
href="https://stackoverflow.com/questions/tagged/pact"><img
|
|
112
|
+
src="https://img.shields.io/badge/stackoverflow-pact-F48024.svg"
|
|
113
|
+
alt="Stack Overflow"></a>
|
|
114
|
+
<a
|
|
115
|
+
href="https://twitter.com/pact_up"><img
|
|
116
|
+
src="https://img.shields.io/badge/X-@pact__up-black.svg"
|
|
117
|
+
alt="Twitter"></a>
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
</table></div>
|
|
121
|
+
<!-- markdownlint-enable no-inline-html -->
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
This sub-package is part of the [Pact Python](https://github.com/pact-foundation/pact-python) project and exists solely to distribute the [Pact CLI](https://github.com/pact-foundation/pact-standalone) as a Python package. If you are looking for the main Pact Python library for contract testing, please see the [root package](https://github.com/pact-foundation/pact-python#pact-python).
|
|
126
|
+
|
|
127
|
+
It is used by version 2 of Pact Python, and can be used to install the Pact CLI in Python environments.
|
|
128
|
+
|
|
129
|
+
The versionining of `pact-python-cli` is aligned with the Pact CLI versioning. For example, version `2.4.26.2` corresponds to Pact CLI version `2.4.26`, with the `.2` indicating that this is the third release of that Pact CLI version in the Python package (with the first release being `.0`).
|
|
130
|
+
|
|
131
|
+
## Installation
|
|
132
|
+
|
|
133
|
+
You can install this package via pip:
|
|
134
|
+
|
|
135
|
+
```console
|
|
136
|
+
pip install pact-python-cli
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
Contributions to this package are generally not required as it contains minimal Python functionality and generally only requires updating the version number. This is done by pushing a tag of the form `pact-python-cli/<version>` which will automatically trigger a release build in the CI pipeline.
|
|
142
|
+
|
|
143
|
+
To contribute to the Pact CLI itself, please refer to the [Pact Ruby Standalone repository](https://github.com/pact-foundation/pact-standalone).
|
|
144
|
+
|
|
145
|
+
For contributing to Pact Python, see the [main contributing guide](https://github.com/pact-foundation/pact-python/blob/main/CONTRIBUTING.md).
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
For questions or support, please visit the [Pact Foundation Slack](https://slack.pact.io) or [GitHub Discussions](https://github.com/pact-foundation/pact-python/discussions).
|
|
150
|
+
|
|
151
|
+
---
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
|
|
2
|
+
# Pact Python CLI
|
|
3
|
+
|
|
4
|
+
> [!NOTE]
|
|
5
|
+
>
|
|
6
|
+
> This package is used to package and bundle the Pact CLI _only_. It does not provide any Python functionality or API.
|
|
7
|
+
|
|
8
|
+
<!-- markdownlint-disable no-inline-html -->
|
|
9
|
+
<div align="center"><table>
|
|
10
|
+
<tr>
|
|
11
|
+
<td>Package</td>
|
|
12
|
+
<td>
|
|
13
|
+
<a href="https://pypi.python.org/pypi/pact-python-cli"><img src="https://img.shields.io/pypi/v/pact-python-cli.svg" alt="Version"></a>
|
|
14
|
+
<a href="https://pypi.python.org/pypi/pact-python-cli"><img src="https://img.shields.io/pypi/pyversions/pact-python-cli.svg" alt="Python Versions"></a>
|
|
15
|
+
<a href="https://pypi.python.org/pypi/pact-python-cli"><img src="https://img.shields.io/pypi/dm/pact-python-cli.svg" alt="Downloads"></a>
|
|
16
|
+
</td>
|
|
17
|
+
</tr>
|
|
18
|
+
<tr>
|
|
19
|
+
<td>CI/CD</td>
|
|
20
|
+
<td>
|
|
21
|
+
<a
|
|
22
|
+
href="https://github.com/pact-foundation/pact-python/actions/workflows/test.yml?query=branch:main"><img
|
|
23
|
+
src="https://img.shields.io/github/actions/workflow/status/pact-foundation/pact-python/test.yml?branch=main&label=test"
|
|
24
|
+
alt="Test Status"></a>
|
|
25
|
+
<a
|
|
26
|
+
href="https://github.com/pact-foundation/pact-python/actions/workflows/build-cli.yml?query=branch:main"><img
|
|
27
|
+
src="https://img.shields.io/github/actions/workflow/status/pact-foundation/pact-python/build-cli.yml?branch=main&label=build"
|
|
28
|
+
alt="Build Status"></a>
|
|
29
|
+
<a
|
|
30
|
+
href="https://github.com/pact-foundation/pact-python/actions/workflows/docs.yml?query=branch:main"><img
|
|
31
|
+
src="https://img.shields.io/github/actions/workflow/status/pact-foundation/pact-python/docs.yml?branch=main&label=docs"
|
|
32
|
+
alt="Build Status"></a>
|
|
33
|
+
</td>
|
|
34
|
+
</tr>
|
|
35
|
+
<tr>
|
|
36
|
+
<td>Meta</td>
|
|
37
|
+
<td>
|
|
38
|
+
<a
|
|
39
|
+
href="https://github.com/pypa/hatch"><img
|
|
40
|
+
src="https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg"
|
|
41
|
+
alt="Hatch project"></a>
|
|
42
|
+
<a href="https://github.com/astral-sh/ruff"><img
|
|
43
|
+
src="https://img.shields.io/badge/ruff-ruff?label=linting&color=%23261230"
|
|
44
|
+
alt="linting - Ruff"></a>
|
|
45
|
+
<a href="https://github.com/astral-sh/ruff"><img
|
|
46
|
+
src="https://img.shields.io/badge/ruff-ruff?label=style&color=%23261230"
|
|
47
|
+
alt="style - Ruff"></a>
|
|
48
|
+
<a
|
|
49
|
+
href="https://github.com/python/mypy"><img
|
|
50
|
+
src="https://img.shields.io/badge/types-Mypy-blue.svg"
|
|
51
|
+
alt="types - Mypy"></a>
|
|
52
|
+
<a
|
|
53
|
+
href="https://pypi.python.org/pypi/pact-python-cli"><img
|
|
54
|
+
src="https://img.shields.io/pypi/l/pact-python-cli.svg"
|
|
55
|
+
alt="License"></a>
|
|
56
|
+
</td>
|
|
57
|
+
</tr>
|
|
58
|
+
<tr>
|
|
59
|
+
<td>Community</td>
|
|
60
|
+
<td>
|
|
61
|
+
<a
|
|
62
|
+
href="https://github.com/pact-foundation/pact-python/issues"><img
|
|
63
|
+
src="https://img.shields.io/github/issues/pact-foundation/pact-python.svg"
|
|
64
|
+
alt="Issues"></a>
|
|
65
|
+
<a
|
|
66
|
+
href="https://github.com/pact-foundation/pact-python/discussions"><img
|
|
67
|
+
src="https://img.shields.io/github/discussions/pact-foundation/pact-python.svg"
|
|
68
|
+
alt="Discussions"></a>
|
|
69
|
+
<a
|
|
70
|
+
href="https://github.com/pact-foundation/pact-python"><img
|
|
71
|
+
src="https://img.shields.io/github/stars/pact-foundation/pact-python.svg?style=flat"
|
|
72
|
+
alt="GitHub Stars"></a>
|
|
73
|
+
<br/>
|
|
74
|
+
<a
|
|
75
|
+
href="http://slack.pact.io"><img
|
|
76
|
+
src="https://img.shields.io/badge/slack-pact--foundation-4A154B.svg"
|
|
77
|
+
alt="Slack"></a>
|
|
78
|
+
<a
|
|
79
|
+
href="https://stackoverflow.com/questions/tagged/pact"><img
|
|
80
|
+
src="https://img.shields.io/badge/stackoverflow-pact-F48024.svg"
|
|
81
|
+
alt="Stack Overflow"></a>
|
|
82
|
+
<a
|
|
83
|
+
href="https://twitter.com/pact_up"><img
|
|
84
|
+
src="https://img.shields.io/badge/X-@pact__up-black.svg"
|
|
85
|
+
alt="Twitter"></a>
|
|
86
|
+
</td>
|
|
87
|
+
</tr>
|
|
88
|
+
</table></div>
|
|
89
|
+
<!-- markdownlint-enable no-inline-html -->
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
This sub-package is part of the [Pact Python](https://github.com/pact-foundation/pact-python) project and exists solely to distribute the [Pact CLI](https://github.com/pact-foundation/pact-standalone) as a Python package. If you are looking for the main Pact Python library for contract testing, please see the [root package](https://github.com/pact-foundation/pact-python#pact-python).
|
|
94
|
+
|
|
95
|
+
It is used by version 2 of Pact Python, and can be used to install the Pact CLI in Python environments.
|
|
96
|
+
|
|
97
|
+
The versionining of `pact-python-cli` is aligned with the Pact CLI versioning. For example, version `2.4.26.2` corresponds to Pact CLI version `2.4.26`, with the `.2` indicating that this is the third release of that Pact CLI version in the Python package (with the first release being `.0`).
|
|
98
|
+
|
|
99
|
+
## Installation
|
|
100
|
+
|
|
101
|
+
You can install this package via pip:
|
|
102
|
+
|
|
103
|
+
```console
|
|
104
|
+
pip install pact-python-cli
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Contributing
|
|
108
|
+
|
|
109
|
+
Contributions to this package are generally not required as it contains minimal Python functionality and generally only requires updating the version number. This is done by pushing a tag of the form `pact-python-cli/<version>` which will automatically trigger a release build in the CI pipeline.
|
|
110
|
+
|
|
111
|
+
To contribute to the Pact CLI itself, please refer to the [Pact Ruby Standalone repository](https://github.com/pact-foundation/pact-standalone).
|
|
112
|
+
|
|
113
|
+
For contributing to Pact Python, see the [main contributing guide](https://github.com/pact-foundation/pact-python/blob/main/CONTRIBUTING.md).
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
For questions or support, please visit the [Pact Foundation Slack](https://slack.pact.io) or [GitHub Discussions](https://github.com/pact-foundation/pact-python/discussions).
|
|
118
|
+
|
|
119
|
+
---
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Hatchling build hook
|
|
2
|
+
Hatchling build hook.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
This build script downloads the binaries and library for the current platform
|
|
6
|
-
and installs them in the `pact` directory under `/bin` and `/lib`.
|
|
7
|
-
|
|
8
|
-
The version of the binaries and library can be controlled with the
|
|
9
|
-
`PACT_BIN_VERSION` and `PACT_LIB_VERSION` environment variables. If these are
|
|
10
|
-
not set, a pinned version will be used instead.
|
|
4
|
+
This hook is responsible for downloading and packaging the Pact CLI.
|
|
11
5
|
"""
|
|
12
6
|
|
|
13
7
|
from __future__ import annotations
|
|
14
8
|
|
|
15
|
-
import logging
|
|
16
9
|
import os
|
|
17
10
|
import shutil
|
|
18
11
|
import sys
|
|
@@ -21,39 +14,51 @@ import tempfile
|
|
|
21
14
|
import urllib.request
|
|
22
15
|
import zipfile
|
|
23
16
|
from pathlib import Path
|
|
24
|
-
from typing import Any
|
|
17
|
+
from typing import TYPE_CHECKING, Any
|
|
18
|
+
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from collections.abc import Mapping, MutableMapping, Sequence
|
|
25
21
|
|
|
26
22
|
from hatchling.builders.config import BuilderConfig
|
|
27
23
|
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
28
24
|
from packaging.tags import sys_tags
|
|
29
25
|
|
|
30
|
-
logger = logging.getLogger(__name__)
|
|
31
|
-
|
|
32
|
-
EXE = ".exe" if os.name == "nt" else ""
|
|
33
26
|
PKG_DIR = Path(__file__).parent.resolve() / "src" / "pact_cli"
|
|
34
|
-
|
|
27
|
+
PACT_CLI_URL = "https://github.com/pact-foundation/pact-standalone/releases/download/v{version}/pact-{version}-{os}-{machine}.{ext}"
|
|
35
28
|
|
|
36
29
|
|
|
37
30
|
class UnsupportedPlatformError(RuntimeError):
|
|
38
|
-
"""
|
|
31
|
+
"""
|
|
32
|
+
Custom error raised when the current platform is not supported.
|
|
33
|
+
"""
|
|
39
34
|
|
|
40
35
|
def __init__(self, platform: str) -> None:
|
|
41
36
|
"""
|
|
42
37
|
Initialize the exception.
|
|
43
38
|
|
|
44
39
|
Args:
|
|
45
|
-
platform:
|
|
40
|
+
platform:
|
|
41
|
+
The unsupported platform.
|
|
46
42
|
"""
|
|
47
43
|
self.platform = platform
|
|
48
44
|
super().__init__(f"Unsupported platform {platform}")
|
|
49
45
|
|
|
50
46
|
|
|
51
47
|
class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
52
|
-
"""
|
|
48
|
+
"""
|
|
49
|
+
Custom hook to download Pact CLI binaries.
|
|
50
|
+
|
|
51
|
+
This build hook is invoked by Hatch during the build process. Within
|
|
52
|
+
`pyproject.toml`, it takes the special name of `custom` (despite the name
|
|
53
|
+
below).
|
|
54
|
+
|
|
55
|
+
For more references, see [Build hook
|
|
56
|
+
plugins](https://hatch.pypa.io/1.3/plugins/build-hook/reference/).
|
|
57
|
+
"""
|
|
53
58
|
|
|
54
59
|
PLUGIN_NAME = "pact-cli"
|
|
55
60
|
|
|
56
|
-
def __init__(self, *args:
|
|
61
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ANN401
|
|
57
62
|
"""
|
|
58
63
|
Initialize the build hook.
|
|
59
64
|
|
|
@@ -62,27 +67,60 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
62
67
|
"""
|
|
63
68
|
super().__init__(*args, **kwargs)
|
|
64
69
|
self.tmpdir = Path(tempfile.TemporaryDirectory().name)
|
|
70
|
+
self.tmpdir.mkdir(parents=True, exist_ok=True)
|
|
71
|
+
|
|
72
|
+
def __del__(self) -> None:
|
|
73
|
+
"""
|
|
74
|
+
Clean up temporary files.
|
|
75
|
+
"""
|
|
76
|
+
shutil.rmtree(self.tmpdir, ignore_errors=True)
|
|
77
|
+
|
|
78
|
+
def clean(self, versions: Sequence[str]) -> None: # noqa: ARG002
|
|
79
|
+
"""
|
|
80
|
+
Code called to clean.
|
|
65
81
|
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
This is called by `hatch clean` or when the `-c`/`--clean` flag is
|
|
83
|
+
passed to `hatch build`.
|
|
84
|
+
"""
|
|
68
85
|
for subdir in ["bin", "lib", "data"]:
|
|
69
86
|
shutil.rmtree(PKG_DIR / subdir, ignore_errors=True)
|
|
70
87
|
|
|
71
88
|
def initialize(
|
|
72
89
|
self,
|
|
73
90
|
version: str, # noqa: ARG002
|
|
74
|
-
build_data:
|
|
91
|
+
build_data: MutableMapping[str, object],
|
|
75
92
|
) -> None:
|
|
76
|
-
"""
|
|
93
|
+
"""
|
|
94
|
+
Code called immediately before each build.
|
|
95
|
+
|
|
96
|
+
The CLI version is inferred from the package metadata. Specifically, the
|
|
97
|
+
first three segments of the version string are used.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
version:
|
|
101
|
+
Not used (but required by the parent class).
|
|
102
|
+
|
|
103
|
+
build_data:
|
|
104
|
+
A mutable mapping to modify in-place used by Hatch when creating
|
|
105
|
+
the final wheel.
|
|
106
|
+
|
|
107
|
+
Raises:
|
|
108
|
+
UnsupportedPlatformError:
|
|
109
|
+
If the CLI cannot be built (presumably due to an
|
|
110
|
+
incompatible platform).
|
|
111
|
+
"""
|
|
77
112
|
cli_version = ".".join(self.metadata.version.split(".")[:3])
|
|
78
113
|
if not cli_version:
|
|
79
|
-
|
|
114
|
+
msg = "Failed to determine Pact CLI version."
|
|
115
|
+
self.app.display_error(msg)
|
|
116
|
+
raise ValueError(msg)
|
|
80
117
|
|
|
81
118
|
try:
|
|
82
|
-
self.
|
|
119
|
+
build_data["force_include"] = self._install(cli_version)
|
|
83
120
|
except UnsupportedPlatformError as err:
|
|
84
121
|
msg = f"Pact CLI is not available for {err.platform}."
|
|
85
|
-
|
|
122
|
+
self.app.display_error(msg)
|
|
123
|
+
raise
|
|
86
124
|
|
|
87
125
|
build_data["tag"] = self._infer_tag()
|
|
88
126
|
|
|
@@ -94,7 +132,7 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
94
132
|
"""
|
|
95
133
|
return next(t.platform for t in sys_tags())
|
|
96
134
|
|
|
97
|
-
def
|
|
135
|
+
def _install(self, version: str) -> Mapping[str, str]:
|
|
98
136
|
"""
|
|
99
137
|
Install the Pact standalone binaries.
|
|
100
138
|
|
|
@@ -104,10 +142,19 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
104
142
|
Args:
|
|
105
143
|
version:
|
|
106
144
|
The Pact CLI version to install.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
A mapping of `src` to `dst` to be used by Hatch when creating the
|
|
148
|
+
wheel. Each `src` is a full path in the current filesystem, and the
|
|
149
|
+
`dst` is the corresponding path within the wheel.
|
|
107
150
|
"""
|
|
108
151
|
url = self._pact_bin_url(version)
|
|
109
|
-
|
|
110
|
-
self.
|
|
152
|
+
artefact = self._download(url)
|
|
153
|
+
self._extract(artefact)
|
|
154
|
+
return {
|
|
155
|
+
str(PKG_DIR / "bin"): "pact_cli/bin",
|
|
156
|
+
str(PKG_DIR / "lib"): "pact_cli/lib",
|
|
157
|
+
}
|
|
111
158
|
|
|
112
159
|
def _pact_bin_url(self, version: str) -> str:
|
|
113
160
|
"""
|
|
@@ -124,13 +171,13 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
124
171
|
platform = self._sys_tag_platform()
|
|
125
172
|
|
|
126
173
|
if platform.startswith("macosx"):
|
|
127
|
-
|
|
174
|
+
os_name = "osx"
|
|
128
175
|
ext = "tar.gz"
|
|
129
176
|
elif "linux" in platform:
|
|
130
|
-
|
|
177
|
+
os_name = "linux"
|
|
131
178
|
ext = "tar.gz"
|
|
132
179
|
elif platform.startswith("win"):
|
|
133
|
-
|
|
180
|
+
os_name = "windows"
|
|
134
181
|
ext = "zip"
|
|
135
182
|
else:
|
|
136
183
|
raise UnsupportedPlatformError(platform)
|
|
@@ -139,19 +186,17 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
139
186
|
machine = "arm64"
|
|
140
187
|
elif platform.endswith(("x86_64", "amd64")):
|
|
141
188
|
machine = "x86_64"
|
|
142
|
-
elif platform.endswith(("i386", "i686", "x86", "win32")):
|
|
143
|
-
machine = "x86"
|
|
144
189
|
else:
|
|
145
190
|
raise UnsupportedPlatformError(platform)
|
|
146
191
|
|
|
147
|
-
return
|
|
192
|
+
return PACT_CLI_URL.format(
|
|
148
193
|
version=version,
|
|
149
|
-
os=
|
|
194
|
+
os=os_name,
|
|
150
195
|
machine=machine,
|
|
151
196
|
ext=ext,
|
|
152
197
|
)
|
|
153
198
|
|
|
154
|
-
def
|
|
199
|
+
def _extract(self, artefact: Path) -> None:
|
|
155
200
|
"""
|
|
156
201
|
Extract the Pact binaries.
|
|
157
202
|
|
|
@@ -159,14 +204,15 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
159
204
|
to be present, which is included in the `lib` directory.
|
|
160
205
|
|
|
161
206
|
Args:
|
|
162
|
-
|
|
207
|
+
artefact:
|
|
208
|
+
The path to the downloaded artefact.
|
|
163
209
|
"""
|
|
164
|
-
if str(
|
|
165
|
-
with zipfile.ZipFile(
|
|
210
|
+
if str(artefact).endswith(".zip"):
|
|
211
|
+
with zipfile.ZipFile(artefact) as f:
|
|
166
212
|
f.extractall(self.tmpdir) # noqa: S202
|
|
167
213
|
|
|
168
|
-
if str(
|
|
169
|
-
with tarfile.open(
|
|
214
|
+
if str(artefact).endswith(".tar.gz"):
|
|
215
|
+
with tarfile.open(artefact) as f:
|
|
170
216
|
f.extractall(self.tmpdir) # noqa: S202
|
|
171
217
|
|
|
172
218
|
for d in ["bin", "lib"]:
|
|
@@ -181,23 +227,24 @@ class PactCliBuildHook(BuildHookInterface[BuilderConfig]):
|
|
|
181
227
|
"""
|
|
182
228
|
Download the target URL.
|
|
183
229
|
|
|
184
|
-
This will download the target URL to the `
|
|
185
|
-
download
|
|
230
|
+
This will download the target URL to the `src/pact_cli/data` directory.
|
|
231
|
+
If the download artefact is already present, the existing artefact's
|
|
232
|
+
path will be returned without downloading it again.
|
|
186
233
|
|
|
187
234
|
Args:
|
|
188
|
-
url:
|
|
235
|
+
url:
|
|
236
|
+
The URL to download
|
|
189
237
|
|
|
190
|
-
|
|
191
|
-
The path to the downloaded
|
|
238
|
+
Returns:
|
|
239
|
+
The path to the downloaded artefact.
|
|
192
240
|
"""
|
|
193
241
|
filename = url.split("/")[-1]
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if not artifact.exists():
|
|
198
|
-
urllib.request.urlretrieve(url, artifact) # noqa: S310
|
|
242
|
+
artefact = PKG_DIR / "data" / filename
|
|
243
|
+
artefact.parent.mkdir(parents=True, exist_ok=True)
|
|
199
244
|
|
|
200
|
-
|
|
245
|
+
if not artefact.exists():
|
|
246
|
+
urllib.request.urlretrieve(url, artefact) # noqa: S310
|
|
247
|
+
return artefact
|
|
201
248
|
|
|
202
249
|
def _infer_tag(self) -> str:
|
|
203
250
|
"""
|
|
@@ -30,8 +30,10 @@ __url__ = "https://github.com/pact-foundation/pact-python"
|
|
|
30
30
|
|
|
31
31
|
import os
|
|
32
32
|
import shutil
|
|
33
|
+
import sys
|
|
33
34
|
import warnings
|
|
34
35
|
from pathlib import Path
|
|
36
|
+
from typing import TYPE_CHECKING
|
|
35
37
|
|
|
36
38
|
from pact_cli.__version__ import (
|
|
37
39
|
__version__ as __version__,
|
|
@@ -40,18 +42,50 @@ from pact_cli.__version__ import (
|
|
|
40
42
|
__version_tuple__ as __version_tuple__,
|
|
41
43
|
)
|
|
42
44
|
|
|
45
|
+
if TYPE_CHECKING:
|
|
46
|
+
from collections.abc import Container, Mapping
|
|
47
|
+
|
|
43
48
|
_USE_SYSTEM_BINS = os.getenv("PACT_USE_SYSTEM_BINS", "").upper() in ("TRUE", "YES")
|
|
44
49
|
_BIN_DIR = Path(__file__).parent.resolve() / "bin"
|
|
50
|
+
_LEGACY_BINS: Container[str] = frozenset((
|
|
51
|
+
"pact-message",
|
|
52
|
+
"pact-mock-service",
|
|
53
|
+
"pact-provider-verifier",
|
|
54
|
+
"pact-stub-service",
|
|
55
|
+
))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _telemetry_env() -> Mapping[str, str]:
|
|
59
|
+
"""
|
|
60
|
+
Get environment variables with Pact telemetry data.
|
|
61
|
+
|
|
62
|
+
Returns a copy of the current environment with the following two keys added:
|
|
63
|
+
|
|
64
|
+
- `PACT_EXECUTING_LANGUAGE`: Set to "python".
|
|
65
|
+
- `PACT_EXECUTING_LANGUAGE_VERSION`: Set to the current Python version
|
|
66
|
+
in "major.minor" format.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Environment dictionary Pact telemetry added.
|
|
70
|
+
"""
|
|
71
|
+
env = os.environ.copy()
|
|
72
|
+
env["PACT_EXECUTING_LANGUAGE"] = "python"
|
|
73
|
+
version = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
74
|
+
env["PACT_EXECUTING_LANGUAGE_VERSION"] = version
|
|
75
|
+
return env
|
|
45
76
|
|
|
46
77
|
|
|
47
78
|
def _exec() -> None:
|
|
48
79
|
"""
|
|
49
|
-
|
|
80
|
+
Execute Pact CLI tools routed through the generated entry points.
|
|
50
81
|
|
|
51
|
-
This is
|
|
52
|
-
|
|
53
|
-
appropriate Pact CLI tool based on the executable name.
|
|
82
|
+
This function is exposed via `pyproject.toml` console scripts and forwards
|
|
83
|
+
the provided command-line arguments to the matching Pact CLI binary.
|
|
54
84
|
|
|
85
|
+
Raises:
|
|
86
|
+
SystemExit:
|
|
87
|
+
If the requested command is unknown or an executable cannot be
|
|
88
|
+
located.
|
|
55
89
|
"""
|
|
56
90
|
import sys # noqa: PLC0415
|
|
57
91
|
|
|
@@ -63,15 +97,26 @@ def _exec() -> None:
|
|
|
63
97
|
"pact-broker",
|
|
64
98
|
"pact-message",
|
|
65
99
|
"pact-mock-service",
|
|
66
|
-
"pact-provider-verifier",
|
|
67
100
|
"pact-plugin-cli",
|
|
68
|
-
"pact-
|
|
101
|
+
"pact-provider-verifier",
|
|
102
|
+
"pact-stub-server",
|
|
69
103
|
"pact-stub-service",
|
|
104
|
+
"pact_mock_server_cli",
|
|
105
|
+
"pact_verifier_cli",
|
|
70
106
|
"pactflow",
|
|
71
107
|
):
|
|
72
108
|
print("Unknown command:", command, file=sys.stderr) # noqa: T201
|
|
73
109
|
sys.exit(1)
|
|
74
110
|
|
|
111
|
+
if command in _LEGACY_BINS:
|
|
112
|
+
warnings.warn(
|
|
113
|
+
f"The '{command}' executable is deprecated and will be removed in "
|
|
114
|
+
"a future release. Please migrate to the new Pact CLI tools. "
|
|
115
|
+
"See: <https://github.com/pact-foundation/pact-standalone>",
|
|
116
|
+
DeprecationWarning,
|
|
117
|
+
stacklevel=2,
|
|
118
|
+
)
|
|
119
|
+
|
|
75
120
|
if not _USE_SYSTEM_BINS:
|
|
76
121
|
executable = _find_executable(command)
|
|
77
122
|
else:
|
|
@@ -89,7 +134,7 @@ def _exec() -> None:
|
|
|
89
134
|
print(f"Command '{command}' not found.", file=sys.stderr) # noqa: T201
|
|
90
135
|
sys.exit(1)
|
|
91
136
|
|
|
92
|
-
os.
|
|
137
|
+
os.execve(executable, [executable, *args], _telemetry_env()) # noqa: S606
|
|
93
138
|
|
|
94
139
|
|
|
95
140
|
def _find_executable(executable: str) -> str | None:
|
|
@@ -117,7 +162,17 @@ def _find_executable(executable: str) -> str | None:
|
|
|
117
162
|
if _USE_SYSTEM_BINS:
|
|
118
163
|
bin_path = shutil.which(executable)
|
|
119
164
|
else:
|
|
120
|
-
bin_path = shutil.which(executable, path=_BIN_DIR)
|
|
165
|
+
bin_path = shutil.which(executable, path=str(_BIN_DIR))
|
|
166
|
+
if bin_path is None:
|
|
167
|
+
system_path = shutil.which(executable)
|
|
168
|
+
if system_path is not None:
|
|
169
|
+
warnings.warn(
|
|
170
|
+
f"Bundled {executable} binary not found; "
|
|
171
|
+
"using system installation instead.",
|
|
172
|
+
RuntimeWarning,
|
|
173
|
+
stacklevel=2,
|
|
174
|
+
)
|
|
175
|
+
bin_path = system_path
|
|
121
176
|
if bin_path is None:
|
|
122
177
|
msg = f"Unable to find {executable} binary executable."
|
|
123
178
|
warnings.warn(msg, RuntimeWarning, stacklevel=2)
|
|
@@ -135,6 +190,9 @@ Path to the Pact Broker executable
|
|
|
135
190
|
BROKER_CLIENT_PATH = _find_executable("pact-broker")
|
|
136
191
|
"""
|
|
137
192
|
Path to the Pact Broker executable
|
|
193
|
+
|
|
194
|
+
This value is identical to `BROKER_PATH` and is provided for backward
|
|
195
|
+
compatibility.
|
|
138
196
|
"""
|
|
139
197
|
MESSAGE_PATH = _find_executable("pact-message")
|
|
140
198
|
"""
|
|
@@ -152,10 +210,25 @@ VERIFIER_PATH = _find_executable("pact-provider-verifier")
|
|
|
152
210
|
"""
|
|
153
211
|
Path to the Pact Provider Verifier executable
|
|
154
212
|
"""
|
|
213
|
+
STUB_SERVER_PATH = _find_executable("pact-stub-server")
|
|
214
|
+
"""
|
|
215
|
+
Path to the Pact Stub Server executable
|
|
216
|
+
"""
|
|
155
217
|
STUB_SERVICE_PATH = _find_executable("pact-stub-service")
|
|
156
218
|
"""
|
|
157
219
|
Path to the Pact Stub Service executable
|
|
158
220
|
"""
|
|
221
|
+
MOCK_SERVER_PATH = _find_executable("pact_mock_server_cli")
|
|
222
|
+
"""
|
|
223
|
+
Path to the Pact Mock Server CLI executable
|
|
224
|
+
"""
|
|
225
|
+
VERIFIER_CLI_PATH = _find_executable("pact_verifier_cli")
|
|
226
|
+
"""
|
|
227
|
+
Path to the Pact Verifier CLI executable
|
|
228
|
+
|
|
229
|
+
This is distinct to the `VERIFIER_PATH` which points to the older Ruby-based
|
|
230
|
+
CLI.
|
|
231
|
+
"""
|
|
159
232
|
PACTFLOW_PATH = _find_executable("pactflow")
|
|
160
233
|
"""
|
|
161
234
|
Path to the PactFlow CLI executable
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
#:schema https://
|
|
1
|
+
#:schema https://www.schemastore.org/pyproject.json
|
|
2
2
|
[project]
|
|
3
3
|
description = "Pact CLI bundle for Python"
|
|
4
4
|
name = "pact-python-cli"
|
|
5
5
|
|
|
6
|
-
dynamic
|
|
7
|
-
|
|
6
|
+
dynamic = ["version"]
|
|
7
|
+
keywords = ["pact", "cli", "pact-python", "contract-testing"]
|
|
8
|
+
license = "MIT"
|
|
9
|
+
readme = "README.md"
|
|
8
10
|
|
|
9
11
|
authors = [{ name = "Joshua Ellis", email = "josh@jpellis.me" }]
|
|
10
12
|
maintainers = [{ name = "Joshua Ellis", email = "josh@jpellis.me" }]
|
|
@@ -22,12 +24,12 @@ classifiers = [
|
|
|
22
24
|
"Programming Language :: Python :: 3.11",
|
|
23
25
|
"Programming Language :: Python :: 3.12",
|
|
24
26
|
"Programming Language :: Python :: 3.13",
|
|
25
|
-
"Programming Language :: Python :: 3.
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
26
28
|
"Programming Language :: Python",
|
|
27
29
|
"Topic :: Software Development :: Testing",
|
|
28
30
|
]
|
|
29
31
|
|
|
30
|
-
requires-python = ">=3.
|
|
32
|
+
requires-python = ">=3.10"
|
|
31
33
|
|
|
32
34
|
[project.urls]
|
|
33
35
|
"Bug Tracker" = "https://github.com/pact-foundation/pact-python/issues"
|
|
@@ -43,63 +45,37 @@ requires-python = ">=3.9"
|
|
|
43
45
|
pact-mock-service = "pact_cli:_exec"
|
|
44
46
|
pact-plugin-cli = "pact_cli:_exec"
|
|
45
47
|
pact-provider-verifier = "pact_cli:_exec"
|
|
48
|
+
pact-stub-server = "pact_cli:_exec"
|
|
46
49
|
pact-stub-service = "pact_cli:_exec"
|
|
50
|
+
pact_mock_server_cli = "pact_cli:_exec"
|
|
51
|
+
pact_verifier_cli = "pact_cli:_exec"
|
|
47
52
|
pactflow = "pact_cli:_exec"
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"ruff==0.12.4",
|
|
56
|
-
]
|
|
57
|
-
devel-test = ["pytest-cov~=6.0", "pytest-mock~=3.0", "pytest~=8.0"]
|
|
58
|
-
devel-types = ["mypy==1.17.0"]
|
|
54
|
+
[dependency-groups]
|
|
55
|
+
# Linting and formatting tools use a more narrow specification to ensure
|
|
56
|
+
# developper consistency. All other dependencies are as above.
|
|
57
|
+
dev = ["ruff==0.14.8", { include-group = "test" }, { include-group = "types" }]
|
|
58
|
+
test = ["pytest-cov~=7.0", "pytest~=9.0"]
|
|
59
|
+
types = ["mypy==1.19.0"]
|
|
59
60
|
|
|
60
61
|
################################################################################
|
|
61
62
|
## Build System
|
|
62
63
|
################################################################################
|
|
63
64
|
[build-system]
|
|
64
65
|
build-backend = "hatchling.build"
|
|
65
|
-
requires
|
|
66
|
-
"hatch-vcs",
|
|
67
|
-
"hatchling",
|
|
68
|
-
"packaging",
|
|
69
|
-
# "setuptools ; python_version >= '3.12'",
|
|
70
|
-
]
|
|
66
|
+
requires = ["hatchling", "packaging", "versioningit"]
|
|
71
67
|
|
|
72
68
|
[tool.hatch]
|
|
73
69
|
|
|
74
70
|
[tool.hatch.version]
|
|
75
|
-
source
|
|
76
|
-
tag-pattern = "^pact-python-cli/(?P<version>[vV]?\\d+(?:\\.\\d+)*)$"
|
|
77
|
-
|
|
78
|
-
[tool.hatch.version.raw-options]
|
|
79
|
-
git_describe_command = [
|
|
80
|
-
"git",
|
|
81
|
-
"describe",
|
|
82
|
-
"--tags",
|
|
83
|
-
"--dirty",
|
|
84
|
-
"--always",
|
|
85
|
-
"--long",
|
|
86
|
-
"--match",
|
|
87
|
-
"pact-python-cli/*",
|
|
88
|
-
]
|
|
89
|
-
root = ".."
|
|
90
|
-
version_scheme = "no-guess-dev"
|
|
71
|
+
source = "versioningit"
|
|
91
72
|
|
|
92
73
|
[tool.hatch.build]
|
|
74
|
+
artifacts = ["src/pact_cli/__version__.py"]
|
|
75
|
+
packages = ["src/pact_cli"]
|
|
93
76
|
|
|
94
|
-
[tool.hatch.build.hooks.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[tool.hatch.build.targets.wheel]
|
|
98
|
-
artifacts = ["src/pact_cli/bin", "src/pact_cli/lib"]
|
|
99
|
-
packages = ["src/pact_cli"]
|
|
100
|
-
|
|
101
|
-
[tool.hatch.build.targets.wheel.hooks.custom]
|
|
102
|
-
patch = "hatch_build.py"
|
|
77
|
+
[tool.hatch.build.targets.wheel.hooks.custom]
|
|
78
|
+
patch = "hatch_build.py"
|
|
103
79
|
|
|
104
80
|
########################################
|
|
105
81
|
## Hatch Environment Configuration
|
|
@@ -115,8 +91,9 @@ requires = [
|
|
|
115
91
|
"requests",
|
|
116
92
|
"setuptools ; python_version >= '3.12'",
|
|
117
93
|
]
|
|
118
|
-
features = ["devel"]
|
|
119
94
|
installer = "uv"
|
|
95
|
+
path = ".venv"
|
|
96
|
+
pre-install-commands = ["uv pip install --group dev -e ."]
|
|
120
97
|
|
|
121
98
|
[tool.hatch.envs.default.scripts]
|
|
122
99
|
all = ["format", "lint", "test", "typecheck"]
|
|
@@ -130,29 +107,48 @@ requires = [
|
|
|
130
107
|
# Test environment for running unit tests. This automatically tests against all
|
|
131
108
|
# supported Python versions.
|
|
132
109
|
[tool.hatch.envs.test]
|
|
133
|
-
|
|
134
|
-
|
|
110
|
+
installer = "uv"
|
|
111
|
+
path = ".venv/test"
|
|
112
|
+
pre-install-commands = ["uv pip install --group test -e ."]
|
|
135
113
|
|
|
136
114
|
[[tool.hatch.envs.test.matrix]]
|
|
137
|
-
python = ["3.10", "3.11", "3.12", "3.13", "3.
|
|
115
|
+
python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
116
|
+
|
|
117
|
+
################################################################################
|
|
118
|
+
## Versioningit Configuration
|
|
119
|
+
################################################################################
|
|
120
|
+
[tool.versioningit]
|
|
121
|
+
[tool.versioningit.vcs]
|
|
122
|
+
match = ["pact-python-cli/*"]
|
|
123
|
+
method = "git"
|
|
124
|
+
|
|
125
|
+
[tool.versioningit.tag2version]
|
|
126
|
+
rmprefix = "pact-python-cli/"
|
|
127
|
+
|
|
128
|
+
[tool.versioningit.write]
|
|
129
|
+
file = "src/pact_cli/__version__.py"
|
|
130
|
+
template = '''\
|
|
131
|
+
# This file is auto-generated by versioningit. Do not edit.
|
|
132
|
+
__version__ = "{version}"
|
|
133
|
+
__version_tuple__ = {version_tuple}
|
|
134
|
+
__commit_id__ = "{revision}"
|
|
135
|
+
'''
|
|
138
136
|
|
|
139
137
|
################################################################################
|
|
140
138
|
## PyTest Configuration
|
|
141
139
|
################################################################################
|
|
142
140
|
[tool.pytest]
|
|
141
|
+
addopts = [
|
|
142
|
+
"--import-mode=importlib",
|
|
143
|
+
# Coverage options
|
|
144
|
+
"--cov-config=pyproject.toml",
|
|
145
|
+
"--cov-report=xml",
|
|
146
|
+
"--cov=pact_cli",
|
|
147
|
+
]
|
|
143
148
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
# Coverage options
|
|
148
|
-
"--cov-config=pyproject.toml",
|
|
149
|
-
"--cov-report=xml",
|
|
150
|
-
"--cov=pact_cli",
|
|
151
|
-
]
|
|
152
|
-
|
|
153
|
-
log_date_format = "%H:%M:%S"
|
|
154
|
-
log_format = "%(asctime)s.%(msecs)03d [%(levelname)-8s] %(name)s: %(message)s"
|
|
155
|
-
log_level = "NOTSET"
|
|
149
|
+
log_date_format = "%H:%M:%S"
|
|
150
|
+
log_format = "%(asctime)s.%(msecs)03d [%(levelname)-8s] %(name)s: %(message)s"
|
|
151
|
+
log_level = "NOTSET"
|
|
156
152
|
|
|
157
153
|
################################################################################
|
|
158
154
|
## Coverage
|
|
@@ -194,6 +190,9 @@ exclude = ''
|
|
|
194
190
|
# with false-positives missing libraries despite being bundled.
|
|
195
191
|
repair-wheel-command = ""
|
|
196
192
|
|
|
193
|
+
[tool.cibuildwheel.windows]
|
|
194
|
+
archs = ["auto64"]
|
|
195
|
+
|
|
197
196
|
[[tool.cibuildwheel.overrides]]
|
|
198
197
|
environment.MACOSX_DEPLOYMENT_TARGET = "10.13"
|
|
199
198
|
select = "*-macosx_x86_64"
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pact-python-cli
|
|
3
|
-
Version: 2.4.26.2
|
|
4
|
-
Summary: Pact CLI bundle for Python
|
|
5
|
-
Project-URL: Bug Tracker, https://github.com/pact-foundation/pact-python/issues
|
|
6
|
-
Project-URL: Changelog, https://github.com/pact-foundation/pact-python/blob/main/pact-python-cli/CHANGELOG.md
|
|
7
|
-
Project-URL: Documentation, https://docs.pact.io
|
|
8
|
-
Project-URL: Homepage, https://pact.io
|
|
9
|
-
Project-URL: Repository, https://github.com/pact-foundation/pact-python
|
|
10
|
-
Author-email: Joshua Ellis <josh@jpellis.me>
|
|
11
|
-
Maintainer-email: Joshua Ellis <josh@jpellis.me>
|
|
12
|
-
License-Expression: MIT
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
-
Classifier: Environment :: Console
|
|
16
|
-
Classifier: Intended Audience :: Developers
|
|
17
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
-
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
-
Classifier: Programming Language :: Python
|
|
22
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
-
Classifier: Topic :: Software Development :: Testing
|
|
29
|
-
Requires-Python: >=3.9
|
|
30
|
-
Provides-Extra: devel
|
|
31
|
-
Requires-Dist: mypy==1.17.0; extra == 'devel'
|
|
32
|
-
Requires-Dist: pytest-cov~=6.0; extra == 'devel'
|
|
33
|
-
Requires-Dist: pytest-mock~=3.0; extra == 'devel'
|
|
34
|
-
Requires-Dist: pytest~=8.0; extra == 'devel'
|
|
35
|
-
Requires-Dist: ruff==0.12.4; extra == 'devel'
|
|
36
|
-
Provides-Extra: devel-test
|
|
37
|
-
Requires-Dist: pytest-cov~=6.0; extra == 'devel-test'
|
|
38
|
-
Requires-Dist: pytest-mock~=3.0; extra == 'devel-test'
|
|
39
|
-
Requires-Dist: pytest~=8.0; extra == 'devel-test'
|
|
40
|
-
Provides-Extra: devel-types
|
|
41
|
-
Requires-Dist: mypy==1.17.0; extra == 'devel-types'
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Pact Python CLI
|
|
3
|
-
|
|
4
|
-
> [!NOTE]
|
|
5
|
-
>
|
|
6
|
-
> This package is used to package and bundle the Pact CLI _only_. It does not provide any Python functionality or API.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
This sub-package is part of the [Pact Python](https://github.com/pact-foundation/pact-python) project and exists solely to distribute the [Pact CLI](https://github.com/pact-foundation/pact-ruby-standalone) as a Python package. If you are looking for the main Pact Python library for contract testing, please see the [root package](https://github.com/pact-foundation/pact-python#pact-python).
|
|
11
|
-
|
|
12
|
-
It is used by version 2 of Pact Python, and can be used to install the Pact CLI in Python environments.
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
You can install this package via pip:
|
|
17
|
-
|
|
18
|
-
```console
|
|
19
|
-
pip install pact-python-cli
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Contributing
|
|
23
|
-
|
|
24
|
-
Contributions to this package are generally not required as it contains minimal Python functionality and generally only requires updating the version number. To contribute to the Pact CLI itself, please refer to the [Pact Ruby Standalone repository](https://github.com/pact-foundation/pact-ruby-standalone).
|
|
25
|
-
|
|
26
|
-
For contributing to Pact Python, see the [main contributing guide](https://github.com/pact-foundation/pact-python/blob/main/CONTRIBUTING.md).
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
For questions or support, please visit the [Pact Foundation Slack](https://slack.pact.io) or [GitHub Discussions](https://github.com/pact-foundation/pact-python/discussions).
|
|
31
|
-
|
|
32
|
-
---
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#:schema https://json.schemastore.org/any.json
|
|
2
|
-
# git-cliff ~ default configuration file
|
|
3
|
-
# https://git-cliff.org/docs/configuration
|
|
4
|
-
|
|
5
|
-
[changelog]
|
|
6
|
-
# template for the changelog header
|
|
7
|
-
header = """
|
|
8
|
-
# Pact Python CLI Changelog
|
|
9
|
-
|
|
10
|
-
All notable changes to this project will be documented in this file.
|
|
11
|
-
|
|
12
|
-
Note that this _only_ includes changes to the Python re-packaging of the Pact CLI. For changes to the Pact CLI itself, see the [Pact CLI changelog](https://github.com/pact-foundation/pact-ruby-standalone/blob/master/CHANGELOG.md).
|
|
13
|
-
|
|
14
|
-
<!-- markdownlint-disable no-duplicate-heading -->
|
|
15
|
-
<!-- markdownlint-disable emph-style -->
|
|
16
|
-
<!-- markdownlint-disable strong-style -->
|
|
17
|
-
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
# template for the changelog body
|
|
21
|
-
# https://keats.github.io/tera/docs/#introduction
|
|
22
|
-
body = """
|
|
23
|
-
{% if version %}\
|
|
24
|
-
## [{{ version | trim_start_matches(pat="v") }}] _{{ timestamp | date(format="%Y-%m-%d") }}_
|
|
25
|
-
{% else %}\
|
|
26
|
-
## [unreleased]
|
|
27
|
-
{% endif %}\
|
|
28
|
-
{% for group, commits in commits | group_by(attribute="group") %}
|
|
29
|
-
### {{ group | striptags | trim | upper_first }}
|
|
30
|
-
{% for commit in commits %}
|
|
31
|
-
- {% if commit.scope %}_({{ commit.scope }})_ {% endif %}\
|
|
32
|
-
{% if commit.breaking %}[**breaking**] {% endif %}\
|
|
33
|
-
{{ commit.message | upper_first }}\
|
|
34
|
-
{% if commit.breaking and commit.breaking_description %}
|
|
35
|
-
{{ " " }}\
|
|
36
|
-
> {{
|
|
37
|
-
commit.breaking_description
|
|
38
|
-
| split(pat="\n")
|
|
39
|
-
| join(sep=" ")
|
|
40
|
-
| replace(from=" ", to=" ")
|
|
41
|
-
| replace(from=" ", to=" ")
|
|
42
|
-
| replace(from=" ", to=" ")
|
|
43
|
-
| upper_first
|
|
44
|
-
}}\
|
|
45
|
-
{% endif %}\
|
|
46
|
-
{% endfor %}
|
|
47
|
-
{% endfor %}
|
|
48
|
-
{% if github.contributors %}\
|
|
49
|
-
### Contributors
|
|
50
|
-
{% for contributor in github.contributors %}\
|
|
51
|
-
{% if contributor.username and contributor.username is ending_with("[bot]") %}{% continue %}{% endif %}
|
|
52
|
-
- @{{ contributor.username }}\
|
|
53
|
-
{% endfor %}
|
|
54
|
-
{% endif %}
|
|
55
|
-
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
# template for the changelog footer
|
|
59
|
-
footer = """\
|
|
60
|
-
<!-- generated by git-cliff on {{ now() | date(format="%Y-%m-%d") }}-->
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
# remove the leading and trailing s
|
|
64
|
-
trim = true
|
|
65
|
-
# postprocessors
|
|
66
|
-
postprocessors = []
|
|
67
|
-
# render body even when there are no releases to process
|
|
68
|
-
# render_always = true
|
|
69
|
-
# output file path
|
|
70
|
-
output = "CHANGELOG.md"
|
|
71
|
-
|
|
72
|
-
[git]
|
|
73
|
-
tag_pattern = "pact-python-cli/.*"
|
|
74
|
-
# parse the commits based on https://www.conventionalcommits.org
|
|
75
|
-
conventional_commits = true
|
|
76
|
-
# filter out the commits that are not conventional
|
|
77
|
-
filter_unconventional = true
|
|
78
|
-
# process each line of a commit as an individual commit
|
|
79
|
-
split_commits = false
|
|
80
|
-
# regex for preprocessing the commit messages
|
|
81
|
-
commit_preprocessors = [
|
|
82
|
-
# Remove the PR number added by GitHub when merging PR in UI
|
|
83
|
-
{ pattern = '\s*\(#([0-9]+)\)$', replace = "" },
|
|
84
|
-
# Check spelling of the commit with https://github.com/crate-ci/typos
|
|
85
|
-
{ pattern = '.*', replace_command = 'typos --write-changes -' },
|
|
86
|
-
]
|
|
87
|
-
# regex for parsing and grouping commits
|
|
88
|
-
commit_parsers = [
|
|
89
|
-
# Ignore deps commits from the changelog
|
|
90
|
-
{ message = "^(chore|fix)\\(deps.*\\)", skip = true },
|
|
91
|
-
{ message = "^chore: update changelog.*", skip = true },
|
|
92
|
-
# Group commits by type
|
|
93
|
-
{ group = "<!-- 00 -->🚀 Features", message = "^feat" },
|
|
94
|
-
{ group = "<!-- 01 -->🐛 Bug Fixes", message = "^fix" },
|
|
95
|
-
{ group = "<!-- 50 -->🚜 Refactor", message = "^refactor" },
|
|
96
|
-
{ group = "<!-- 51 -->⚡ Performance", message = "^perf" },
|
|
97
|
-
{ group = "<!-- 52 -->🎨 Styling", message = "^style" },
|
|
98
|
-
{ group = "<!-- 60 -->📚 Documentation", message = "^docs" },
|
|
99
|
-
{ group = "<!-- 80 -->🧪 Testing", message = "^test" },
|
|
100
|
-
{ group = "<!-- 98 -->◀️ Revert", message = "^revert" },
|
|
101
|
-
{ group = "<!-- 99 -->⚙️ Miscellaneous Tasks", message = "^chore" },
|
|
102
|
-
{ group = "<!-- 99 -->� Other", message = ".*" },
|
|
103
|
-
]
|
|
104
|
-
# filter out the commits that are not matched by commit parsers
|
|
105
|
-
filter_commits = false
|
|
106
|
-
# sort the tags topologically
|
|
107
|
-
topo_order = false
|
|
108
|
-
# sort the commits inside sections by oldest/newest order
|
|
109
|
-
sort_commits = "oldest"
|
|
110
|
-
|
|
111
|
-
[remote.github]
|
|
112
|
-
owner = "pact-foundation"
|
|
113
|
-
repo = "pact-python"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# file generated by setuptools-scm
|
|
2
|
-
# don't change, don't track in version control
|
|
3
|
-
|
|
4
|
-
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
-
|
|
6
|
-
TYPE_CHECKING = False
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
from typing import Tuple
|
|
9
|
-
from typing import Union
|
|
10
|
-
|
|
11
|
-
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
12
|
-
else:
|
|
13
|
-
VERSION_TUPLE = object
|
|
14
|
-
|
|
15
|
-
version: str
|
|
16
|
-
__version__: str
|
|
17
|
-
__version_tuple__: VERSION_TUPLE
|
|
18
|
-
version_tuple: VERSION_TUPLE
|
|
19
|
-
|
|
20
|
-
__version__ = version = '2.4.26.2'
|
|
21
|
-
__version_tuple__ = version_tuple = (2, 4, 26, 2)
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#:schema https://json.schemastore.org/ruff.json
|
|
2
|
-
extend = "../pyproject.toml"
|
|
3
|
-
|
|
4
|
-
[lint]
|
|
5
|
-
ignore = [
|
|
6
|
-
"D103", # Require docstrings on public functions
|
|
7
|
-
"INP001", # Forbid implicit namespaces
|
|
8
|
-
"PLR2004", # Forbid magic numbers
|
|
9
|
-
"S101", # Disable assert
|
|
10
|
-
]
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"""Test the values in exported constants."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import shutil
|
|
7
|
-
import subprocess
|
|
8
|
-
import sys
|
|
9
|
-
import time
|
|
10
|
-
from pathlib import Path
|
|
11
|
-
from typing import TYPE_CHECKING
|
|
12
|
-
|
|
13
|
-
import pytest
|
|
14
|
-
|
|
15
|
-
import pact_cli
|
|
16
|
-
|
|
17
|
-
if TYPE_CHECKING:
|
|
18
|
-
from unittest.mock import MagicMock
|
|
19
|
-
|
|
20
|
-
import pytest_mock
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def bin_to_sitepackages(exec_path: str | Path) -> Path:
|
|
24
|
-
"""
|
|
25
|
-
Find the expected site-packages directory for the given executable.
|
|
26
|
-
"""
|
|
27
|
-
if os.name == "nt":
|
|
28
|
-
return Path(exec_path).parents[1] / "Lib" / "site-packages"
|
|
29
|
-
return (
|
|
30
|
-
Path(exec_path).parents[1]
|
|
31
|
-
/ "lib"
|
|
32
|
-
/ f"python{sys.version_info.major}.{sys.version_info.minor}"
|
|
33
|
-
/ "site-packages"
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def assert_in_sys_path(p: str | Path) -> None:
|
|
38
|
-
"""
|
|
39
|
-
Assert that a given path is in sys.path.
|
|
40
|
-
|
|
41
|
-
This performs some normalization on platform where the filesystem is
|
|
42
|
-
case-insensitive.
|
|
43
|
-
"""
|
|
44
|
-
if os.name == "nt":
|
|
45
|
-
assert str(p).lower() in (path.lower() for path in sys.path)
|
|
46
|
-
else:
|
|
47
|
-
assert str(p) in sys.path
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@pytest.mark.parametrize(
|
|
51
|
-
("constant", "expected"),
|
|
52
|
-
[
|
|
53
|
-
pytest.param("PACT_PATH", "pact", id="pact"),
|
|
54
|
-
pytest.param("BROKER_PATH", "pact-broker", id="pact-broker"),
|
|
55
|
-
pytest.param("BROKER_CLIENT_PATH", "pact-broker", id="pact-broker"),
|
|
56
|
-
pytest.param("MESSAGE_PATH", "pact-message", id="pactmessage"),
|
|
57
|
-
pytest.param("MOCK_SERVICE_PATH", "pact-mock-service", id="pact-message"),
|
|
58
|
-
pytest.param("PLUGIN_CLI_PATH", "pact-plugin-cli", id="pact-plugin-cli"),
|
|
59
|
-
pytest.param(
|
|
60
|
-
"VERIFIER_PATH", "pact-provider-verifier", id="pact-provider-verifier"
|
|
61
|
-
),
|
|
62
|
-
pytest.param("STUB_SERVICE_PATH", "pact-stub-service", id="pact-stub-service"),
|
|
63
|
-
pytest.param("PACTFLOW_PATH", "pactflow", id="pactflow"),
|
|
64
|
-
],
|
|
65
|
-
)
|
|
66
|
-
def test_constants(constant: str, expected: str) -> None:
|
|
67
|
-
"""Test the values of constants in pact.constants."""
|
|
68
|
-
value: str = getattr(pact_cli, constant)
|
|
69
|
-
if os.name == "nt":
|
|
70
|
-
# As the Windows filesystem is case insensitive, we must normalize it.
|
|
71
|
-
assert value.lower().endswith((f"{expected}.bat", f"{expected}.exe"))
|
|
72
|
-
else:
|
|
73
|
-
assert value.endswith(expected)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
@pytest.mark.parametrize(
|
|
77
|
-
"executable",
|
|
78
|
-
[
|
|
79
|
-
pytest.param("pact", id="pact"),
|
|
80
|
-
pytest.param("pact-broker", id="pact-broker"),
|
|
81
|
-
pytest.param("pact-message", id="pact-message"),
|
|
82
|
-
pytest.param("pact-plugin-cli", id="pact-plugin-cli"),
|
|
83
|
-
pytest.param("pact-provider-verifier", id="pact-provider-verifier"),
|
|
84
|
-
pytest.param("pact-stub-service", id="pact-stub-service"),
|
|
85
|
-
pytest.param("pactflow", id="pactflow"),
|
|
86
|
-
],
|
|
87
|
-
)
|
|
88
|
-
def test_exec_wrapper(executable: str) -> None:
|
|
89
|
-
exec_path = shutil.which(executable)
|
|
90
|
-
assert exec_path
|
|
91
|
-
|
|
92
|
-
site_packages = bin_to_sitepackages(exec_path)
|
|
93
|
-
assert site_packages.is_dir()
|
|
94
|
-
assert_in_sys_path(site_packages)
|
|
95
|
-
|
|
96
|
-
result = subprocess.run( # noqa: S603
|
|
97
|
-
[exec_path, "--help"],
|
|
98
|
-
check=False, # Some CLIs return non-zero for --help
|
|
99
|
-
text=True,
|
|
100
|
-
capture_output=True,
|
|
101
|
-
)
|
|
102
|
-
assert "pact" in (result.stdout + result.stderr).lower()
|
|
103
|
-
|
|
104
|
-
result = subprocess.run( # noqa: S603
|
|
105
|
-
[exec_path],
|
|
106
|
-
check=False, # Some CLIs return non-zero for --help
|
|
107
|
-
text=True,
|
|
108
|
-
capture_output=True,
|
|
109
|
-
)
|
|
110
|
-
assert "pact" in (result.stdout + result.stderr).lower()
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def test_exec_wrapper_mock_service() -> None:
|
|
114
|
-
"""
|
|
115
|
-
Analogous to test_exec_wrapper, but specifically for pact-mock-service.
|
|
116
|
-
|
|
117
|
-
This is necessary because pact-mock-service is a long running service, so we
|
|
118
|
-
spawn the process, terminate it after a delay, and check the output.
|
|
119
|
-
"""
|
|
120
|
-
executable = "pact-mock-service"
|
|
121
|
-
exec_path = shutil.which(executable)
|
|
122
|
-
assert exec_path
|
|
123
|
-
site_packages = bin_to_sitepackages(exec_path)
|
|
124
|
-
assert site_packages.is_dir()
|
|
125
|
-
assert_in_sys_path(site_packages)
|
|
126
|
-
|
|
127
|
-
process = subprocess.Popen( # noqa: S603
|
|
128
|
-
[exec_path],
|
|
129
|
-
stdout=subprocess.PIPE,
|
|
130
|
-
stderr=subprocess.PIPE,
|
|
131
|
-
text=True,
|
|
132
|
-
)
|
|
133
|
-
time.sleep(1)
|
|
134
|
-
process.terminate()
|
|
135
|
-
process.wait()
|
|
136
|
-
|
|
137
|
-
stdout, stderr = process.communicate()
|
|
138
|
-
assert "pact" in (stdout + stderr).lower()
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
@pytest.mark.parametrize(
|
|
142
|
-
"executable",
|
|
143
|
-
[
|
|
144
|
-
pytest.param("pact", id="pact"),
|
|
145
|
-
pytest.param("pact-broker", id="pact-broker"),
|
|
146
|
-
pytest.param("pact-message", id="pact-message"),
|
|
147
|
-
pytest.param("pact-mock-service", id="pact-mock-service"),
|
|
148
|
-
pytest.param("pact-plugin-cli", id="pact-plugin-cli"),
|
|
149
|
-
pytest.param("pact-provider-verifier", id="pact-provider-verifier"),
|
|
150
|
-
pytest.param("pact-stub-service", id="pact-stub-service"),
|
|
151
|
-
pytest.param("pactflow", id="pactflow"),
|
|
152
|
-
],
|
|
153
|
-
)
|
|
154
|
-
def test_exec_directly(executable: str, mocker: pytest_mock.MockerFixture) -> None:
|
|
155
|
-
"""
|
|
156
|
-
Test pact_cli._exec with --help, mocking sys.argv and capturing output.
|
|
157
|
-
"""
|
|
158
|
-
cmd: str
|
|
159
|
-
args: list[str]
|
|
160
|
-
|
|
161
|
-
mocker.patch.object(sys, "argv", new=[executable, "--help"])
|
|
162
|
-
mock_execv: MagicMock = mocker.patch("os.execv")
|
|
163
|
-
pact_cli._exec() # noqa: SLF001
|
|
164
|
-
mock_execv.assert_called_once()
|
|
165
|
-
cmd, args = mock_execv.call_args[0]
|
|
166
|
-
assert (os.sep + executable) in cmd
|
|
167
|
-
assert args == [cmd, "--help"]
|
|
168
|
-
|
|
169
|
-
mocker.patch.object(sys, "argv", new=[executable])
|
|
170
|
-
mock_execv.reset_mock()
|
|
171
|
-
pact_cli._exec() # noqa: SLF001
|
|
172
|
-
mock_execv.assert_called_once()
|
|
173
|
-
cmd, args = mock_execv.call_args[0]
|
|
174
|
-
assert (os.sep + executable) in cmd
|
|
175
|
-
assert args == [cmd]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|