Skip to main content

A collection of convenient testing utilities for Python

Project description

pytools

A collection of Python testing utilities.

Installation

pip install fixturify

Modules

Module Description Docs
sql Execute SQL files before/after tests docs/sql.md
read Inject JSON fixtures into test functions docs/read.md
http Record and replay HTTP calls docs/http.md
JsonAssert Compare objects to JSON files docs/json_assert.md
ObjectMapper Bidirectional object-JSON mapping docs/object_mapper.md

Quick examples

sql

from fixturify import sql, Phase

@sql(path="./setup.sql")
@sql(path="./cleanup.sql", phase=Phase.AFTER)
def test_database():
    # SQL executed before and after test
    pass

read

from fixturify import read

@read.fixture(path="./fixtures/user.json", fixture_name="user", object_class=User)
def test_user(user: User):
    assert user.name == "John"

http

from fixturify import http

@http(path="./fixtures/api.json")
def test_api():
    # First run: records HTTP calls
    # Next runs: replays from file
    response = requests.get("https://api.example.com/users")
    assert response.status_code == 200

JsonAssert

from fixturify import JsonAssert

def test_response():
    data = {"name": "John", "age": 30}
    JsonAssert(data).ignore("age").compare_to_file("./expected.json")

ObjectMapper

from fixturify import ObjectMapper

# Object to JSON
user = User(name="John", age=30)
data = ObjectMapper(user).to_json()

# JSON to object
data = {"name": "John", "age": 30}
user = ObjectMapper(data).to_object(User)

Public API

from fixturify import (
    # Decorators
    sql,
    read,
    http,
    # Enums
    Phase,
    # Config
    SqlTestConfig,
    HttpTestConfig,
    # Classes
    JsonAssert,
    ObjectMapper,
)

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

fixturify-0.1.9.tar.gz (265.2 kB view details)

Uploaded Source

Built Distribution

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

fixturify-0.1.9-py3-none-any.whl (92.3 kB view details)

Uploaded Python 3

File details

Details for the file fixturify-0.1.9.tar.gz.

File metadata

  • Download URL: fixturify-0.1.9.tar.gz
  • Upload date:
  • Size: 265.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fixturify-0.1.9.tar.gz
Algorithm Hash digest
SHA256 93479fade8272962b4e8fbec855be0bf48ac2535d8087c20d611f90b54de0ef3
MD5 2a2fec99fa92f6db0588871ca4bde42f
BLAKE2b-256 9da7a69f9b1cc42a4794a491a3575fd05566e76b7ac0ea45717c9ecf64ad588b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fixturify-0.1.9.tar.gz:

Publisher: publish.yml on eleven-sea/pytools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fixturify-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: fixturify-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 92.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fixturify-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 905b5d281619fcb4f88a3a5bbb4b3f6df47ea4e23512f9c57d5e6c497a5ae834
MD5 4deba9b21e3a75ed175bb1f268b72dc2
BLAKE2b-256 342412ccd66aa6a75d9298fb21c83113c10ef875ba25b70ab0c2f96521e73d85

See more details on using hashes here.

Provenance

The following attestation bundles were made for fixturify-0.1.9-py3-none-any.whl:

Publisher: publish.yml on eleven-sea/pytools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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