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
Copy file name to clipboardExpand all lines: README.md
+57-20Lines changed: 57 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,28 @@ Default client fixture names the plugin will look for (in order):
189
189
190
190
If you use a different fixture name, you can provide one or more names via the CLI flag `--api-cov-client-fixture-names` (repeatable) or in `pyproject.toml` under `[tool.pytest_api_cov]` as `client_fixture_names` (a list).
191
191
192
-
#### Option 1: Helper Function
192
+
193
+
#### Option 1: Configuration-Based (recommended for most users)
194
+
195
+
Configure one or more existing fixture names to be discovered and wrapped automatically by the plugin.
196
+
197
+
Example `pyproject.toml`:
198
+
199
+
```toml
200
+
[tool.pytest_api_cov]
201
+
# Provide a list of candidate fixture names the plugin should try (order matters)
If the configured fixture(s) are not found, the plugin will try to use an `app` fixture (if present) to create a tracked client. If neither is available or the plugin cannot extract the app from a discovered client fixture, the tests will still run — coverage will simply be unavailable and a warning will be logged.
212
+
213
+
#### Option 2: Helper Function
193
214
194
215
Use the `create_coverage_fixture` helper to create a custom fixture name:
If the configured fixture(s) are not found, the plugin will try to use an `app` fixture (if present) to create a tracked client. If neither is available or the plugin cannot extract the app from a discovered client fixture, the tests will still run — coverage will simply be unavailable and a warning will be logged.
# Group HTTP methods by endpoint for legacy behavior (default: false)
282
286
group_methods_by_endpoint = false
283
287
288
+
```
289
+
Notes on exclusion patterns
290
+
291
+
- Method prefixes (optional): If a pattern starts with one or more HTTP method names followed by whitespace, the pattern applies only to those methods. Methods may be comma-separated and are matched case-insensitively. Example: `GET,POST /users/*`.
292
+
- Path-only patterns (default): If no method is specified the pattern applies to all methods for the matching path (existing behaviour).
293
+
- Wildcards: Use `*` to match any characters in the path portion (not a regex; dots and other characters are treated literally unless `*` is used).
294
+
- Negation: Prefix a pattern with `!` to override earlier exclusions and re-include a path (or method-specific path). Negations can also include method prefixes (e.g. `!GET /admin/health`).
295
+
- Matching: Patterns are tested against both the full `METHOD /path` string and the `/path` portion to remain compatible with existing configurations.
296
+
297
+
Examples (pyproject or CLI):
298
+
299
+
- Exclude the `/health` path for all methods:
300
+
301
+
```toml
302
+
exclusion_patterns = ["/health"]
303
+
```
304
+
305
+
- Exclude only GET requests to `/health`:
306
+
307
+
```toml
308
+
exclusion_patterns = ["GET /health"]
309
+
```
310
+
311
+
- Exclude GET and POST for `/users/*` but re-include GET /users/42:
0 commit comments