Skip to main content

SWARD

Works just like Ward, but has some new fixes and features, since the original project was archived.

New features

Fixes

  • The traceback panel now uses the full terminal width (no more a small 100px box)

  • Breakpoint statements are working again

  • Event loop bugs fixed

Installation:

  pip install sward

From now on, it's the same thing from Ward's original repo...


Codecov Documentation Status PyPI version


Ward is a Python testing framework with a focus on productivity and readability. It gives you the tools you need to write well-documented and scalable tests.

Ward typical test output example

Features

See the full set of features in the documentation.

Descriptive test names: describe what your tests do using strings, not function names.

@test("simple addition")  # you can use markdown in these descriptions!
def _():
    assert 1 + 2 == 3  # you can use plain assert statements!

Modular test dependencies: manage test setup/teardown code using fixtures that rely on Python's import system, not name matching.

@fixture
def user():
    return User(name="darren")


@test("the user is called darren")
def _(u=user):
    assert u.name == "darren"

Support for asyncio: define your tests and fixtures with async def and call asynchronous code within them.

@fixture
async def user():
    u = await create_user()
    return await u.login()


@test("the logged in user has a last session date")
async def _(user=user):
    last_session = await get_last_session_date(user.id)
    assert is_recent(last_session, get_last_session_date)

Powerful test selection: limit your test run not only by matching test names/descriptions, but also on the code contained in the body of the test.

ward --search "Database.get_all_users"

Or use tag expressions for more powerful filtering.

ward --tags "(unit or integration) and not slow"

Parameterised testing: write a test once, and run it multiple times with different inputs by writing it in a loop.

for lhs, rhs, res in [
    (1, 1, 2),
    (2, 3, 5),
]:

    @test("simple addition")
    def _(left=lhs, right=rhs, result=res):
        assert left + right == result

Cross platform: Tested on Mac OS, Linux, and Windows.

Speedy: Ward's suite of ~320 tests run in less than half a second on my machine.

Zero config: Sensible defaults mean running ward with no arguments is enough to get started. Can be configured using pyproject.toml or the command line if required.

Extendable: Ward has a plugin system built with pluggy, the same framework used by pytest.

Colourful, human readable output: quickly pinpoint and fix issues with detailed output for failing tests.

Ward failing test output example

Getting Started

Have a look at the documentation!

How to Contribute

Contributions are very welcome and encouraged!

See the contributing guide for information on how you can take part in the development of Ward.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sward-0.70.2.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sward-0.70.2-py3-none-any.whl (44.3 kB view details)

Uploaded Python 3

File details

Details for the file sward-0.70.2.tar.gz.

File metadata

  • Download URL: sward-0.70.2.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.0 CPython/3.12.13 Linux/7.0.0-31-generic

File hashes

Hashes for sward-0.70.2.tar.gz
Algorithm Hash digest
SHA256 7ad957ce6d6c0297f107f822493cbecc6f4f2e95a5ca045e28e949fc74a130a4
MD5 81020baf60175e678113cabefa3f960c
BLAKE2b-256 576214f560e46fa8e9f19789212e2c4276f98c8ff20010729d3391b4858eda06

See more details on using hashes here.

File details

Details for the file sward-0.70.2-py3-none-any.whl.

File metadata

  • Download URL: sward-0.70.2-py3-none-any.whl
  • Upload date:
  • Size: 44.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.0 CPython/3.12.13 Linux/7.0.0-31-generic

File hashes

Hashes for sward-0.70.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c108ce0bf977483f5265a413b1da1be2ecb823ae6a056d716b69a50cd0c0f579
MD5 5e7ba5721f17fb420b1530521843f7c9
BLAKE2b-256 db9e02b694aa5886f40bae16a9939290bd1f0c534e4e3e3acf580f334d780a02

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.70.2 This release

2 files

0.70.1

2 files

0.70.0

2 files

0.69.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page