Ward - A modern Python test framework¶
Ward is a modern test framework for Python with a focus on productivity and readability.
Features¶
Describe your tests using strings instead of function names
Use plain
assert
statements, with no need to rememberassert*
method namesBeautiful output that focuses on readability
Supported on MacOS, Linux, and Windows
Manage test dependencies using a simple but powerful fixture system
Support for testing async code
Parameterised testing allows you to run a single test on multiple inputs
Configurable with pyproject.toml, but works out-of-the-box with sensible defaults
Speedy – Ward’s suite of ~300 tests completes in ~0.4 seconds on my machine
Installation¶
Ward is available on PyPI, and can be installed with pip install ward
(Python 3.6+ required).
A Quick Taste¶
Here’s a simple example of a test written using Ward:
# file: test_example.py
from ward import test
@test("the list contains 42")
def _():
assert 42 in [-21, 42, 999]
To run the test, simply run ward
in your terminal, and Ward will let you know how it went:
- Writing Tests
- Running Tests
- Test outcomes
- Specifying test paths with
--path
- Excluding modules or paths with
--exclude
- Selecting tagged tests with
--tags
- Loosely search for tests with
--search
- Customising the output with
--test-output-style
- Displaying test session progress with
--progress-style
- Output capturing
- Randomise test execution order with
--order random
- Cancelling after a number of failures with
--fail-limit
- Finding slow running tests with
--show-slowest
- Performing a dry run with
--dry-run
- Displaying symbols in diffs with
--show-diff-symbols
- Debugging your code with
pdb
/breakpoint()
- Fixtures
- Configuration