Skip to main content

Type-safe and maintainable fixtures and parametrization for pytest.

Project description

pytypest

Type-safe and maintainable fixtures and parametrization for pytest.

Features:

  • 100% type safe.
  • Great IDE integration, go-to-definition always takes you in the right place.
  • Test parametrization that is redable even with many arguments.
  • Plug-and-play integration with pytest.
  • No vendor-lock, you can use only the features you need and don't touch the rest.
  • Fixtures can be cached, and you are in control of for how long.
  • Fixtures can accept arguments.

Installation

python3 -m pip install pytypest

Usage

Fixtures are regular helper functions that yield their result and do teardown afterwards:

from typing import Iterator
from pytypest import fixture

@fixture
def get_user(anonymous: bool) -> Iterator[User]:
    u = User(anonymous=anonymous)
    u.save()
    yield u
    u.delete()

def test_user() -> None:
    u = get_user(anonymous=False)
    assert u.anonymous is False

Compared to built-in pytest fixtures, these are explicit, type-safe, can accept arguments, support go-to-definition in IDE, and can be used as context managers. And like pytest fixtures, they are cached and can be scoped to the module or the whole session.

Read more in the documentation: pytypest.orsinium.dev.

Project details


Download files

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

Source Distribution

pytypest-1.0.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

pytypest-1.0.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file pytypest-1.0.0.tar.gz.

File metadata

  • Download URL: pytypest-1.0.0.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for pytypest-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4ae787fde3afb612c8241cdd8b50d95c16d0a51e22929edb23155f194b06dc77
MD5 17fe9a6735a3e192e75857b2e1d32231
BLAKE2b-256 db3f52ca45c06002e39bf0be8e85c0131521790b5967c7c12617b95803bf9b60

See more details on using hashes here.

File details

Details for the file pytypest-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytypest-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for pytypest-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cd912e169a5226cde6572b689486855ce5decf326ee57986cb9c0888a9bf547
MD5 04fe37563fbdfe97d7b94b6816c536c6
BLAKE2b-256 05af762044ffd90a20037db94c9d59917463d637ba760299da8f749246250079

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page