Skip to content

Commit 5821f4e

Browse files
committed
chore: upgrade pymdownx extensions
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]>
1 parent d19bcdb commit 5821f4e

File tree

19 files changed

+446
-458
lines changed

19 files changed

+446
-458
lines changed

MIGRATION.md

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -242,139 +242,139 @@ verifier = (
242242

243243
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.
244244

245-
<!-- markdownlint-disable code-block-style -->
245+
/// tab | Local Files
246246

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+
```
248253

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+
```
255263

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+
///
265265

266-
=== "Pact Broker"
266+
/// tab | Pact Broker
267267

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+
```
275275

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'
284283
)
284+
)
285285

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
297292
)
298-
```
293+
.include_pending()
294+
.provider_branch('main')
295+
.consumer_tags('main', 'develop')
296+
.build()
297+
)
298+
```
299299

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.
301301

302-
<!-- markdownlint-enable code-block-style -->
302+
///
303303

304304
#### Provider State Handling
305305

306306
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.
307307

308-
<!-- markdownlint-disable code-block-style -->
308+
/// tab | URL-based State Handling
309309

310-
=== "URL-based State Handling"
310+
```python title="v2"
311+
success, logs = verifier.verify_pacts(
312+
'./pacts/consumer-provider.json',
313+
provider_states_setup_url='http://localhost:8080/_pact/provider_states'
314+
)
315+
```
311316

312-
```python title="v2"
313-
success, logs = verifier.verify_pacts(
314-
'./pacts/consumer-provider.json',
315-
provider_states_setup_url='http://localhost:8080/_pact/provider_states'
317+
```python title="v3"
318+
# Option 1: URL-based (similar to v2)
319+
verifier = (
320+
Verifier('my-provider')
321+
.add_transport(url='http://localhost:8080')
322+
.state_handler(
323+
'http://localhost:8080/_pact/provider_states',
324+
body=True # (1)
316325
)
317-
```
326+
.add_source('./pacts/')
327+
)
328+
```
318329

319-
```python title="v3"
320-
# Option 1: URL-based (similar to v2)
321-
verifier = (
322-
Verifier('my-provider')
323-
.add_transport(url='http://localhost:8080')
324-
.state_handler(
325-
'http://localhost:8080/_pact/provider_states',
326-
body=True # (1)
327-
)
328-
.add_source('./pacts/')
329-
)
330-
```
331-
332-
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].
333-
334-
=== "Functional State Handling"
335-
336-
```python title="v2"
337-
# Not supported
338-
```
339-
340-
```python title="v3 - Function"
341-
def handler(name, params=None):
342-
if name == 'user exists':
343-
# Set up user in database/mock
344-
create_user(params.get('id', 123))
345-
elif name == 'no users exist':
346-
# Clear users
347-
clear_users()
348-
349-
verifier = (
350-
Verifier('my-provider')
351-
.add_transport(url='http://localhost:8080')
352-
.state_handler(handler)
353-
.add_source('./pacts/')
354-
)
355-
```
356-
357-
```python title="v3 - Mapping"
358-
state_handlers = {
359-
'user exists': lambda name, params: create_user(params.get('id', 123)),
360-
'no users exist': lambda name, params: clear_users(),
361-
}
330+
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].
331+
332+
///
333+
334+
//// tab | Functional State Handling
335+
336+
```python title="v2"
337+
# Not supported
338+
```
339+
340+
```python title="v3 - Function"
341+
def handler(name, params=None):
342+
if name == 'user exists':
343+
# Set up user in database/mock
344+
create_user(params.get('id', 123))
345+
elif name == 'no users exist':
346+
# Clear users
347+
clear_users()
362348

363349
verifier = (
364350
Verifier('my-provider')
365351
.add_transport(url='http://localhost:8080')
366-
.state_handler(state_handlers)
352+
.state_handler(handler)
367353
.add_source('./pacts/')
368354
)
369-
```
355+
```
356+
357+
```python title="v3 - Mapping"
358+
state_handlers = {
359+
'user exists': lambda name, params: create_user(params.get('id', 123)),
360+
'no users exist': lambda name, params: clear_users(),
361+
}
370362

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.
363+
verifier = (
364+
Verifier('my-provider')
365+
.add_transport(url='http://localhost:8080')
366+
.state_handler(state_handlers)
367+
.add_source('./pacts/')
368+
)
369+
```
372370

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.
374372

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`).
375+
///
376376

377-
<!-- markdownlint-enable code-block-style -->
377+
////
378378

379379
#### Message Verification
380380

docs/blog/posts/2024/04-11 a sneak peek into the pact python future.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ Happy testing!
6969

7070
----
7171

72-
<!-- markdownlint-disable code-block-style -->
72+
/// define
7373
1 August 2025
74-
: With the release of Pact Python `v3`, some hyperlinks have been removed from this blog post as they are no longer relevant.
75-
<!-- markdownlint-enable code-block-style -->
74+
75+
- With the release of Pact Python `v3`, some hyperlinks have been removed from this blog post as they are no longer relevant.
76+
///

docs/blog/posts/2024/07-26 asynchronous message support.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ At present, it is the responsibility of the end user to set up the provider endp
186186
187187
---
188188
189-
<!-- markdownlint-disable code-block-style -->
189+
/// define
190190
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.
193+
///

0 commit comments

Comments
 (0)