You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use the newer `code.*` extensions as they are much more compatible with
various other Markdown linters/parsers/syntax highlighters.
Signed-off-by: JP-Ellis <[email protected]>
Support for both local files and Pact Brokers is retained in v3, with the `verify_pacts` and `verify_with_broker` methods replaced by a more flexible source configuration. This allows multiple sources to be combined, and selectors to be applied.
244
244
245
-
<!-- markdownlint-disable code-block-style -->
245
+
/// tab | Local Files
246
246
247
-
=== "Local Files"
247
+
```python title="v2"
248
+
success, logs = verifier.verify_pacts(
249
+
'./pacts/consumer1-provider.json',
250
+
'./pacts/consumer2-provider.json'
251
+
)
252
+
```
248
253
249
-
```python title="v2"
250
-
success, logs = verifier.verify_pacts(
251
-
'./pacts/consumer1-provider.json',
252
-
'./pacts/consumer2-provider.json'
253
-
)
254
-
```
254
+
```python title="v3"
255
+
verifier = (
256
+
Verifier('my-provider')
257
+
# It can discover all Pact files in a directory
258
+
.add_source('./pacts/')
259
+
# Or read individual files
260
+
.add_source('./pacts/specific-consumer.json')
261
+
)
262
+
```
255
263
256
-
```python title="v3"
257
-
verifier = (
258
-
Verifier('my-provider')
259
-
# It can discover all Pact files in a directory
260
-
.add_source('./pacts/')
261
-
# Or read individual files
262
-
.add_source('./pacts/specific-consumer.json')
263
-
)
264
-
```
264
+
///
265
265
266
-
=== "Pact Broker"
266
+
/// tab | Pact Broker
267
267
268
-
```python title="v2"
269
-
success, logs = verifier.verify_with_broker(
270
-
broker_url='https://pact-broker.example.com',
271
-
broker_username='username',
272
-
broker_password='password'
273
-
)
274
-
```
268
+
```python title="v2"
269
+
success, logs = verifier.verify_with_broker(
270
+
broker_url='https://pact-broker.example.com',
271
+
broker_username='username',
272
+
broker_password='password'
273
+
)
274
+
```
275
275
276
-
```python title="v3"
277
-
verifier = (
278
-
Verifier('my-provider')
279
-
.broker_source(
280
-
'https://pact-broker.example.com',
281
-
username='username',
282
-
password='password'
283
-
)
276
+
```python title="v3"
277
+
verifier = (
278
+
Verifier('my-provider')
279
+
.broker_source(
280
+
'https://pact-broker.example.com',
281
+
username='username',
282
+
password='password'
284
283
)
284
+
)
285
285
286
-
# Or with selectors for more control
287
-
broker_builder = (
288
-
verifier
289
-
.broker_source(
290
-
'https://pact-broker.example.com',
291
-
selector=True
292
-
)
293
-
.include_pending()
294
-
.provider_branch('main')
295
-
.consumer_tags('main', 'develop')
296
-
.build()
286
+
# Or with selectors for more control
287
+
broker_builder = (
288
+
verifier
289
+
.broker_source(
290
+
'https://pact-broker.example.com',
291
+
selector=True
297
292
)
298
-
```
293
+
.include_pending()
294
+
.provider_branch('main')
295
+
.consumer_tags('main', 'develop')
296
+
.build()
297
+
)
298
+
```
299
299
300
-
The `selector=True` argument returns a [`BrokerSelectorBuilder`][pact.verifier.BrokerSelectorBuilder] instance, which provides methods to configure which pacts to fetch. The `build()` call finalizes the configuration and returns the `Verifier` instance which can then be further configured.
300
+
The `selector=True` argument returns a [`BrokerSelectorBuilder`][pact.verifier.BrokerSelectorBuilder] instance, which provides methods to configure which pacts to fetch. The `build()` call finalizes the configuration and returns the `Verifier` instance which can then be further configured.
301
301
302
-
<!-- markdownlint-enable code-block-style -->
302
+
///
303
303
304
304
#### Provider State Handling
305
305
306
306
The old v2 API required the provider to expose an HTTP endpoint dedicated to handling provider states. This is still supported in v3, but there are now more flexible options, allowing Python functions (or mappings of state names to functions) to be used instead.
1. The `body` argument specifies whether to use a `POST` request and pass information in the body, or to use a `GET` request and pass information through HTTP headers. For more details, see the [`state_handler` API documentation][pact.verifier.Verifier.state_handler].
1. The `body` argument specifies whether to use a `POST` request and pass information in the body, or to use a `GET` request and pass information through HTTP headers. For more details, see the [`state_handler` API documentation][pact.verifier.Verifier.state_handler].
More information on the state handler function signature can be found in the [`state_handler` API documentation][pact.verifier.Verifier.state_handler]. By default, the handlers only _set up_ the provider state. If you need to also _tear down_ the state after verification, you can use the `teardown=True` argument to enable this behaviour.
363
+
verifier = (
364
+
Verifier('my-provider')
365
+
.add_transport(url='http://localhost:8080')
366
+
.state_handler(state_handlers)
367
+
.add_source('./pacts/')
368
+
)
369
+
```
372
370
373
-
!!! warning
371
+
More information on the state handler function signature can be found in the [`state_handler` API documentation][pact.verifier.Verifier.state_handler]. By default, the handlers only _set up_ the provider state. If you need to also _tear down_ the state after verification, you can use the `teardown=True` argument to enable this behaviour.
374
372
375
-
These functions run in the test process, so any side effects must be properly shared with the provider. If using mocking libraries, ensure the provider is started in a separate thread of the same process (using `threading.Thread` or similar), rather than a separate process (e.g., using `multiprocessing.Process` or `subprocess.Popen`).
373
+
/// warning
374
+
These functions run in the test process, so any side effects must be properly shared with the provider. If using mocking libraries, ensure the provider is started in a separate thread of the same process (using `threading.Thread` or similar), rather than a separate process (e.g., using `multiprocessing.Process` or `subprocess.Popen`).
Copy file name to clipboardExpand all lines: docs/blog/posts/2024/07-26 asynchronous message support.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,7 +186,8 @@ At present, it is the responsibility of the end user to set up the provider endp
186
186
187
187
---
188
188
189
-
<!-- markdownlint-disable code-block-style -->
189
+
/// define
190
190
1 August 2025
191
-
: With the release of Pact Python `v3` and the splitting of the CLI and FFI into standalone packages, some hyperlinks and code snippets have been updated to point to the new locations. The _text_ has been kept unchanged to preserve the original context and intent of the post.
192
-
<!-- markdownlint-enable code-block-style -->
191
+
192
+
- With the release of Pact Python `v3` and the splitting of the CLI and FFI into standalone packages, some hyperlinks and code snippets have been updated to point to the new locations. The _text_ has been kept unchanged to preserve the original context and intent of the post.
0 commit comments