Skip to content

Commit

Permalink
feat(docs): Add marks field to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Aug 30, 2024
1 parent 34dd915 commit e8eedeb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/writing_tests/test_markers.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,25 @@ def test_something_with_all_tx_types(

Ideally, the lambda function should be used to explicitly filter out values that are not compatible with the test (exclusive filter), rather than explicitly selecting values (inclusive filter), as the parametrized values might change with future forks.

#### `marks`

A marker, list of markers, or a lambda function that can be used to add additional markers to the test.

```python
import pytest

@pytest.mark.with_all_tx_types(
marks=lambda tx_type: pytest.mark.skip("incompatible") if tx_type == 1 else None,
)
@pytest.mark.valid_from("London")
def test_something_with_all_tx_types_but_skip_type_1(state_test_only, tx_type):
assert tx_type != 1
...
```

In this example, the test will be skipped if `tx_type` is equal to 1 by returning a `pytest.mark.skip` marker, and return `None` otherwise.


Check failure on line 274 in docs/writing_tests/test_markers.md

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11, stable, tox run-parallel --parallel-no-spinner)

Multiple consecutive blank lines

docs/writing_tests/test_markers.md:274 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md012.md

Check failure on line 274 in docs/writing_tests/test_markers.md

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11, stable, tox run-parallel --parallel-no-spinner)

Multiple consecutive blank lines

docs/writing_tests/test_markers.md:274 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md012.md
## Other Markers

### `@pytest.mark.slow`
Expand Down

0 comments on commit e8eedeb

Please sign in to comment.