Ruud Welling
09/24/2024, 12:10 PMArtur Neumann
10/02/2024, 7:40 AMArtur Neumann
10/03/2024, 11:00 AMArtur Neumann
10/03/2024, 11:03 AMuri = f"{self.base_uri}/users/{user_id}"
in https://github.com/pact-foundation/pact-python/blob/0bbae63eeb4580f8c4680c07841604c1a4c05f48/examples/src/consumer.py#L103
becomes
uri = f"{self.base_uri}/user/{user_id}"
when I run the tests I get a huge long error that is hard to understand and really don't tells me what is going on(see message above)
What is the solution to that? I can wrap every test in a try/except block:
try:
with pact.serve() as srv:
client = UserConsumer(str(srv.url))
user = client.get_user(123)
assert user.id == 123
assert user.name == "Verna Hampton"
except MismatchesError as e:
print("Missmatch Error(s):")
print("----------------")
for mismatch in e._mismatches:
for item in mismatch.keys():
print(item, ':', mismatch[item])
print("----------------")
Is that the way to go, or is there an more elegant error to get a better error reporting?Marcus Couto
10/04/2024, 4:16 PMArtur Neumann
10/07/2024, 6:48 AMtest_00_consumer.py
I get only one interaction in the JSON file.
shouldn't overwrite
be set to False
in
https://github.com/pact-foundation/pact-python/blob/0bbae63eeb4580f8c4680c07841604c1a4c05f48/examples/tests/v3/test_00_consumer.py#L52
?GitHub
10/10/2024, 4:14 AMsrv.mismatches
is changed from a list[dict[str, Any]]
to a list[Mismatch]
.
Feat
• add Python 3.13, drop 3.8
• improve mismatch error
• add ArrayContainsMatcher
• add each key/value matchers
• add uuid matcher
• add match aliases
• improve match module
• add strftime to java date format converter
• add matchable typevar
• examples: add post and delete
Fix
• ISO 8601 incompatibility
• typing annotations
• examples: do not publish postgres port
• examples: use wget for broker healthcheck
• examples: do not overwrite pact file on every test
• ensure matchers optionally use generators
• kwargs typing
• incompatible override
• missing typing arguments
Refactor
• match module
• generators module
• create pact.v3.types module
• generate module in style of match module
• rename generators to generate
• matcher
• split types into stub
• rename matchers to match
• prefer |
over Optional and Union
Pull Requests
What's Changed
• chore: update changelog by @JP-Ellis in #739
• chore(deps): update docker/setup-qemu-action digest to 49b3bc8 by @renovate in #741
• chore(ci): use pypi trusted publishing by @JP-Ellis in #740
• chore(deps): update pactfoundation/pact-broker:latest docker digest to 18f0b8b by @renovate in #742
• Docs/async blog by @JP-Ellis in #744
• adding http_matcher.feature v3 compatibility test by @valkolovos in #751
• chore(deps): update pactfoundation/pact-broker:latest docker digest to b521072 by @renovate in #760
• chore(deps): update pre-commit hook commitizen-tools/commitizen to v3.29.0 by @renovate in #756
• chore(deps): update dependency ruff to v0.5.7 - autoclosed by @renovate in #754
• chore(deps): update pypa/cibuildwheel action to v2.20.0 by @renovate in #752
• chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.5.7 by @renovate in #743
• chore(deps): update dependency mypy to v1.11.1 by @renovate in #753
• chore(deps): update actions/upload-artifact digest to 834a144 by @renovate in #750
• chore(deps): update ubuntu:24.04 docker digest to 8a37d68 by @renovate in #765
• chore: regroup ruff in renovate by @JP-Ellis in #766
• chore(deps): update ruff to v0.6.1 by @renovate in #764
• chore: add extra checks by @JP-Ellis in #767
• chore(deps): pin dependencies by @renovate in #768
• chore(deps): update pre-commit hook crate-ci/typos to v1.23.7 by @renovate in #769
• chore(deps): update pre-commit hook crate-ci/typos to v1.24.1 by @renovate in #771
• chore(deps): update dependency mypy to v1.11.2 by @renovate in #772
• chore(deps): update actions/setup-python digest to f677139 by @renovate in #774
• chore: added v3 http interaction examples by @amit828as in #773
• chore(deps): update pre-commit hook crate-ci/typos to v1.24.3 by @renovate in #775
• chore(deps): update pypa/gh-action-pypi-publish action to v1.10.0 by @renovate in #776
• chore(deps): update actions/upload-artifact digest to 5076954 by @renovate in #777
• chore(deps): update ruff to v0.6.3 by @renovate in #770
• chore(deps): update pypa/gh-action-pypi-publish action to v1.10.1 by @renovate in #778
• chore(deps): update pre-commit hook crate-ci/typos to v1.24.4 by @renovate in #780
• chore(deps): update ruff to v0.6.4 by @renovate in #782
• chore(deps): update pre-commit hook crate-ci/typos to v1.24.5 by @renovate in #781
• chore(deps): update peter-evans/create-pull-request action to v7 by @renovate in #779
• chore(deps): update peter-evans/create-pull-request digest to d121e62 by @renovate in #784
• chore(deps): update peter-evans/create-pull-request digest to 6cd32fd by @renovate in #787
• chore(deps): update ruff to v0.6.5 by @renovate in #785
• chore(deps): update pypa/cibuildwheel action to v2.21.0 by @renovate in #786
• chore(deps): update pre-commit hook crate-ci/typos to v1.24.6 by @renovate in #788
• chore(deps): update ubuntu:24.04 docker digest to 56a8952 by @renovate in #789
• chore(deps): update pypa/cibuildwheel action to v2.21.1 by @renovate in #790
• chore(deps): update peter-evans/create-pull-request digest to 5e91468 by @renovate in #794
• chore(deps): update pre-commit hook biomejs/pre-commit to v0.5.0 - autoclosed by @renovate in #793
• chore(deps): update ubuntu:24.04 docker digest to dfc1087 by @renovate in #791
• chore(deps): …
pact-foundation/pact-pythonRamon Saraiva
10/11/2024, 1:27 PMRuntimeError:
An error was raised while verifying the message. The response body is: {"detail":"No matched handler."}
the example is simple, only to understand how its works:
consumer.py
# consumer.py
from pact import MessageConsumer, Provider
# Função principal do consumer
def run_consumer():
# Define o contrato do consumer
contract = MessageConsumer(
"my_contract Consumer"
).has_pact_with(
Provider("my_contract Provider"),
pact_dir="pacts",
)
# Define os dados do evento
event_data = {
"invoice_id": "12345",
"amount": 100.00,
"currency": "USD"
}
# Cria uma mensagem que representa o evento
contract.given("Create contract").expects_to_receive(
"An event of contract").with_content(event_data)
with contract:
pass
if __name__ == "__main__":
run_consumer()
provider:
# provider.py
from pact import MessageProvider
def process_invoice_event(event):
invoice_id = event.get("invoice_id")
amount = event.get("amount")
currency = event.get("currency")
# Validação simples
if not invoice_id or amount <= 0:
return {"status": "error", "message": "Invalid invoice data"}
print(f"Processing invoice: ID = {invoice_id}, Amount = {amount} {currency}")
return event
def run_provider():
simulated_event = {
"invoice_id": "12345",
"amount": 100.00,
"currency": "USD"
}
provider = MessageProvider(
message_providers={
"An event of contract": lambda: process_invoice_event(simulated_event),
},
provider="my_contract Provider",
pact_dir="pacts",
consumer="my_contract Consumer",
)
with provider:
provider.verify()
if __name__ == "__main__":
run_provider()
Gianluca Ciccarelli
11/26/2024, 2:42 PMMartin Mineo
11/27/2024, 6:05 PMpact-python
v3. When running the provider tests, I’m getting an error that I don’t know how to solve
in my test I’m doing
def test_provider() -> None:
proc = Process(target=run_server, daemon=True)
proc.start()
time.sleep(2)
verifier = Verifier().set_info(name="pact-api-py", url=PROVIDER_URL)
verifier.add_source("pacts/pact-http-consumer-py-pact-api-py.json")
verifier.set_state(
PROVIDER_URL / "_pact" / "callback",
teardown=True,
)
verifier.verify()
proc.terminate()
and the error I’m getting is
def verifier_new_for_application() -> VerifierHandle:
"""
Get a Handle to a newly created verifier.
By default, verification results will not be published. To enable
publishing, use
[`pactffi_verifier_set_publish_options`][pact.v3.ffi.verifier_set_publish_options]
to set the required values and enable it.
[Rust
`pactffi_verifier_new_for_application`](<https://docs.rs/pact_ffi/0.4.22/pact_ffi/?search=pactffi_verifier_new_for_application>)
"""
from pact import __version__
result: cffi.FFI.CData = lib.pactffi_verifier_new_for_application(
b"pact-python",
> __version__.encode("utf-8"),
)
E AttributeError: module 'pact.__version__' has no attribute 'encode'
.venv/lib/python3.11/site-packages/pact/v3/ffi.py:6764: AttributeError
The issue is caused by this line __version__.encode("utf-8")
, am I doing something wrong or there’s a bug in v3?Martin Mineo
12/02/2024, 6:37 PMpact-python
v3. I’d like to know if it’s possible to upload the pact files to a broker from a Consumer and the get the files from the Provider.
How can I do it? I know that it can be done with the previous version, but I can’t find how to do it with v3Val Kolovos
12/03/2024, 4:24 PMVal Kolovos
12/04/2024, 8:50 PMArtur Neumann
12/05/2024, 11:21 AMassert
So far I have been using the same port for every test for the pact server and when one test fails other random tests also would fail with RuntimeError: Pact mock server could not be started for PactHandle(64169).
I am just changing it to use a random port, so its not an issue anymore for me. But wanted to know if that is a bug or feature?Pietro Di Bello
12/17/2024, 11:23 AMJoshua Ellis
12/30/2024, 11:05 PMpact.v3
preview!
Unfortunately, this means that the v2.3.0
release will have breaking changes within the pact.v3
interface. You can view the details of the breaking changes in my recent blog post.
I want to thank everyone who has been using pact.v3
and providing feedback, and I hope that the new features help significantly with the user experience, despite the breaking changes.GitHub
12/31/2024, 12:02 AMmessage_handler
signature has been changed and
expanded.
• set_state
has been renamed to state_handler
. If
using a URL still, the body
keyword argument is now a required
parameter.
• The provider name must be given as an argument of the
Verifier
constructor, instead of the first argument of the
set_info
method.
BREAKING CHANGE: The set_info
verifier method is removed, with
add_transport
needing to be used.
Signed-off-by: JP-Ellis josh@jpellis.me
• pact.v3.util
has been renamed to pact.v3._util
and
is now private.
• The PactServer __exit__
arguments no longer have
leading underscores. This is typically handled by Python itself and
therefore is unlikely to be a change for any user, unless the end
user was calling the __exit__
method explicitly and using
keyword arguments.
Feat
• v3: further simplify message interface
• v3: add state handler server
• v3: integrate message relay server
• v3: add message relay and callback servers
Fix
• deps: update dependency mypy to v1.14.1
• deps: update dependency mypy to v1.14.0
• deps: update ruff to v0.8.4
• deps: update ruff to v0.8.3
• deps: update dependency pytest-cov to v6
Pull Requests
What's Changed
• chore: update changelog by @JP-Ellis in #826
• chore(deps): update actions/upload-artifact digest to b4b15b8 by @renovate in #817
• chore(deps): update astral-sh/setup-uv action to v3.1.6 by @renovate in #828
• chore(deps): update astral-sh/setup-uv action to v3.1.7 by @renovate in #831
• chore(deps): update dependency mypy to v1.12.0 by @renovate in #830
• chore(deps): update ubuntu:24.04 docker digest to d4f6f70 by @renovate in #827
• chore: fix url by @JP-Ellis in #832
• chore(deps): update ruff to v0.7.0 by @renovate in #833
• chore(deps): update dependency mypy to v1.12.1 by @renovate in #835
• chore(deps): update ubuntu:24.04 docker digest to 99c3519 by @renovate in #834
• chore(deps): update actions/checkout digest to 11bd719 by @renovate in #839
• chore(deps): update pre-commit hook crate-ci/typos to v1.26.1 by @renovate in #838
• chore(deps): update actions/cache digest to 6849a64 by @renovate in #836
• chore(deps): update dependency mypy to v1.13.0 by @renovate in #837
• chore(deps): update pre-commit hook crate-ci/typos to v1.26.8 by @renovate in #841
• chore(deps): update ruff to v0.7.1 by @renovate in #840
• chore(deps): update astral-sh/setup-uv action to v3.2.0 by @renovate in #842
• fix(deps): update dependency pytest-cov to v6 by @renovate in #843
• chore(deps): update pre-commit hook crate-ci/committed to v1.1.0 by @renovate in #845
• chore(deps): update pypa/gh-action-pypi-publish action to v1.11.0 by @renovate in #844
• chore(deps): update softprops/action-gh-release digest to e7a8f85 by @renovate in #847
• chore(deps): update pre-commit hook crate-ci/committed to v1.1.1 by @renovate in #846
• chore(deps): update pre-commit hook crate-ci/typos to v1.27.0 by @renovate in #849
• chore(deps): update ruff to v0.7.2 by @renovate in #848
• chore(deps): update astral-sh/setup-uv action to v3.2.1 by @renovate in #852
• chore(deps): update pypa/gh-action-pypi-publish action to v1.12.0 by @renovate in #851
• chore(deps): update pre-commit hook crate-ci/typos to v1.27.1 by @renovate in #854
• chore(deps): update astral-sh/setup-uv action to v3.2.2 by @renovate in #853
• chore(deps): update pypa/gh-action-pypi-publish action to v1.12.1 by @renovate in #855
• chore(deps): update pypa/gh-action-pypi-publish action to v1.12.2 by @renovate in #857
• chore(deps): update pre-commit hook crate-ci/typos to v1.27.2 by @renovate in #856
• chore(deps): update pre-commit hook crate-ci/typos to v1.27.3 by @renovate in #860
• chore(deps): update ruff to v0.7.3 by @renovate in #859
• chore(deps): update softprops/action-gh-release action to v2.1.0 by @renovate in #861
• chore(deps): update codecov/codecov-action action to v5 by @renovate in #862
• chore(deps): update codecov/codecov-action action to v5.0.2 by @renovate in #866
• chore(deps): update astral-sh/setup-uv action to v3.2.3 by @renovate in #864
• chore(deps): update ubuntu:24.04 docker digest to 278628f by @renovate in #867
• chore(deps): update codecov/codecov-action action to v5.0.3 by @renovate in #868
• chore(deps): update codecov/codecov-action action to v5.0.6 by @renovate in #869
• chore(deps): update codecov/codecov-action action to v5.0.7 by <https://github.com/re…
pact-foundation/pact-pythonRamon Saraiva
01/17/2025, 5:09 PMTom Lopez
01/22/2025, 4:04 PMGitHub
01/23/2025, 12:07 AMSpencer
02/11/2025, 3:34 PMVal Kolovos
02/27/2025, 6:20 PMpact-python
2.3.1, and I have a feature request. It would appear that neither the state_handler
nor the message_handler
functions in the v3 Verifier
can be async
functions. Is it possible to allow for that? Should I just create an issue in the github repo?Ruud Welling
03/05/2025, 8:05 AMpact.v3
:
We have our verifier configured with include_pending
enabled. When a consumer publishes a pact on a branch, a webhook triggers the verification and the CI output states
> This pact is in pending state for this version of ProviderName because a successful verification result for ProviderName has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending
It also shows that the test fails:
> has a matching body (FAILED)
2 questions:
• I see that the broker shows all results as green, even though some tests failed, is this a bug?
• After the change got merged, the pact on main was shown as NOT pending, and caused the build to fail. Why was the pact considered pending when it was still on the branch, but not on main? (there was a previous successful verification on main before for a different version of that pact)Adam Mitchell
04/22/2025, 8:21 AMVasyl
04/22/2025, 9:31 PMPendingDeprecationWarning: This class will be deprecated Pact Python v3 (see pact-foundation/pact-python#396)
messages make me try to find V3 release timeframe, but I don't have luck finding it so far.
Is there any estimation of when v3 might be available, End of 2025? middle of 2026? 🤔Jun Yi
04/28/2025, 3:36 AMverifier = Verifier().set_info(name=PROVIDER_NAME, url=PROVIDER_URL)
verifier.broker_source(url=URL(settings.pact_flow_url), token=settings.pact_broker_token)
verifier.set_state(url=PROVIDER_URL / "_pact" / "callback", teardown=True)
verifier.filter_consumers(consumer_name)
verifier.set_publish_options(version=str(version))
verifier.verify()
Thanks for your help!Patrick
04/28/2025, 12:39 PMLachlan Newman
05/01/2025, 11:13 PMset_publish_options
but what is the behaviour if that function is not called ?GitHub
05/07/2025, 3:33 AMThe signature of functional arguments must form a subset of the### 📚 Documentation • Replace commitizen with git cliff • Update blog post • Rename params -> parameters • (example) Elaborate on state handler ### ⚙️ Miscellaneous Tasks • Update pre-commit hooks • Update committed configuration • Add taplo • (ci) Update ubuntu runners • Reduce noise from taiki-e/install-action • (ci) Upload test results to codecov • Add apply_arg utility • (tests) Use consistent return value • (test) Tweak type signature • (examples) Fix state handler args ### Contributors • @JP-Ellis ## Pull Requests ## What's Changed • chore: update changelog by @JP-Ellis in #937 • chore: update pre-commit hooks by @JP-Ellis in #939 • chore: update committed configuration by @JP-Ellis in #940 • docs: replace commitizen with git cliff by @JP-Ellis in #938 • chore: add taplo by @JP-Ellis in #941 • chore(deps): update codecov/codecov-action action to v5.3.0 by @renovate in #944 • chore(deps): update taiki-e/install-action action to v2.47.24 by @renovate in #942 • fix(deps): update ruff to v0.9.3 by @renovate in #943 • chore(deps): update codecov/codecov-action action to v5.3.1 by @renovate in #946 • chore(deps): update taiki-e/install-action action to v2.47.25 by @renovate in #947 • chore(deps): update pre-commit hook igorshubovych/markdownlint-cli to v0.44.0 by @renovate in #948 • chore(deps): update pypa/gh-action-pypi-publish action to v1.12.4 by @renovate in #945 • chore(deps): update taiki-e/install-action action to v2.47.26 by @renovate in #949 • chore(deps): update taiki-e/install-action action to v2.47.28 by @renovate in #950 • chore(deps): update taiki-e/install-action action to v2.47.29 by @renovate in #951 • chore(deps): update taiki-e/install-action action to v2.47.30 by @renovate in #952 • fix(deps): update ruff to v0.9.4 by @renovate in #956 • chore(deps): update taiki-e/install-action action to v2.47.31 by @renovate in #954 • chore(deps): update astral-sh/setup-uv action to v5.2.2 by @renovate in #955 • chore(deps): update pre-commit hook crate-ci/typos to v1.29.5 by @renovate in #957 • chore(deps): update taiki-e/install-action action to v2.48.1 by @renovate in #958 • fix(deps): update dependency mypy to v1.15.0 by @renovate in #960 • chore(deps): update docker/setup-qemu-action action to v3.4.0 by @renovate in #962 • chore(deps): update pre-commit hook biomejs/pre-commit to v1 by @renovate in #961 • fix(deps): update ruff to v0.9.5 by @renovate in #963 • chore(deps): update tests/v3/compatibility_suite/definition digest to cc76eac by @renovate in #573 • chore(deps): update taiki-e/install-action action to v2.48.2 by @renovate in #964 • chore(deps): update taiki-e/install-action action to v2.48.4 by @renovate in #965 • chore(deps): update taiki-e/install-action action to v2.48.5 by @renovate in #966 • fix(deps): update ruff to v0.9.6 by @renovate in #969 • chore(deps): update taiki-e/install-action action to v2.48.6 by @renovate in #968 • chore(deps): update taiki-e/install-action action to v2.48.7 by @renovate in #970 • chore(deps): update taiki-e/install-action action to v2.48.9 by @renovate in #971 • chore(deps): update pre-commit hook crate-ci/typos to v1.29.7 by @renovate in #974 • chore(deps): update pactfoundation/pact-broker:latest docker digest to 1abd7da by @renovate in #973 • chore(deps): update taiki-e/install-action action to v2.48.10 by @renovate in #972 • chore(deps): update taiki-e/install-action action to v2.48.12 by @renovate in #976 • fix(deps): update dependency psutil to v7 by @renovate in #977 • chore(deps): update taiki-e/install-action action to v2.48.13 by @renovate in #978 • chore(deps): update taiki-e/install-action action to v2.48.14 by @renovate in #979 • chore(deps): update actions/cache action to v4.2.1 by @renovate in #980 • chore(deps): update taiki-e/install-action action to v2.48.15 by @renovate in #981 • chore(deps): update pre-commit hook crate-ci/typos to v1.29.8 by @renovate in <https://github.com/pact-foundation/pact-python/pull/982|#… pact-foundation/pact-pythonandMessageProducerArgs
typed dictionaries.StateHandlerArgs
Joshua Ellis
05/07/2025, 3:37 AM