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-todefinition 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.

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-0.1.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

pytypest-0.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytypest-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d0837a2456e670424ea50e8123220526399948fab054661eaa06c2eab3a066b
MD5 748637069055d28fbdbd03afb9e03a98
BLAKE2b-256 7a6b766d7c9bf029bd5198b41ce72f3c14160842ac82947a1a36b423c81f977f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pytypest-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 291286fe819c2b24cc6c6db74502769a5a849a6534c2720f8c5d3cacdf43f3a8
MD5 70e609ef3a8cacef48b90b19ec600ebc
BLAKE2b-256 c7698598f73cf4799241381800a1654f879975e854f156128abe53dbd41ccec3

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