Skip to main content

iil-testkit

Shared Test Factory Package for all Platform Django repos — ADR-100

PyPI

Installation

pip install iil-testkit

In requirements-test.txt:

iil-testkit>=0.4.0

With DRF support:

iil-testkit[drf]>=0.4.0

Extras / Optional Dependencies

Extra Additional deps Purpose
drf djangorestframework>=3.14 DRF APIClient fixtures (drf_api_client, drf_auth_client)
django django>=4.2, pytest-django>=4.8 Explicit Django pin (normally pulled transitively)
smoke django, beautifulsoup4>=4.12 HTML smoke assertions

Quick Setup

In your tests/conftest.py:

pytest_plugins = ["iil_testkit.fixtures"]

Factories

# tests/factories.py — import shared, extend repo-specific
from iil_testkit.factories import UserFactory  # noqa: F401
import factory

class MyModelFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = "myapp.MyModel"
    user = factory.SubFactory(UserFactory)

For multi-tenant repos:

from iil_testkit.contrib.tenants import TenantFactory  # noqa: F401

Fixtures

Fixture Description
db_user Standard active user, saved to DB
staff_user User with is_staff=True
admin_user User with is_superuser=True
api_client Unauthenticated Django Client
auth_client Django Client logged in as db_user
staff_client Django Client logged in as staff_user
drf_api_client Unauthenticated DRF APIClient (skips if DRF missing)
drf_auth_client DRF APIClient authenticated as db_user (skips if DRF missing)
def test_should_view_dashboard(auth_client):
    response = auth_client.get("/dashboard/")
    assert response.status_code == 200

def test_should_require_auth(api_client):
    from iil_testkit.assertions import assert_redirects_to_login
    response = api_client.get("/protected/")
    assert_redirects_to_login(response)

Assertion Helpers

from iil_testkit.assertions import (
    assert_redirects_to_login,
    assert_htmx_response,
    assert_no_n_plus_one,
    assert_form_error,
)
Helper Description
assert_redirects_to_login(response) Asserts 301/302 to /login or /accounts/login
assert_htmx_response(response) Asserts no full <html> page in HTMX partial
assert_no_n_plus_one(queries, threshold=5) Asserts query count within threshold
assert_form_error(response, field, message) Asserts form field error in context

Naming Convention Plugin (ADR-057)

Auto-registered when installed. All test functions must follow test_should_*:

Naming convention violations — 1 test(s) must start with 'test_should_':
  tests/test_foo.py::test_login

Opt-out per test:

@pytest.mark.no_naming_convention
def test_legacy_name(): ...

Opt-out globally: pytest --relax-naming

Warn instead of error: iil_naming_mode = "warn" in pyproject.toml

Architecture

See ADR-100.

Metadata

Release files for iil-testkit 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iil-testkit 0.6.1
File Size Uploaded Provenance
iil_testkit-0.6.1.tar.gz 47.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for iil-testkit 0.6.1
File Interpreter ABI Platform
iil_testkit-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 74.2 kB

Release files / iil_testkit-0.6.1.tar.gz

Download URL iil_testkit-0.6.1.tar.gz
Size 47.4 kB
Tags Source
SHA-256 checksum
How to use checksums
885b5a4ae207d411956d68123beafd0d95ef4f487ce862bdf04d7f09acf00262
BLAKE2b-256 checksum
How to use checksums
6eb8b0425b76b20073023c6271537e6b287ca2a2055970111eac0ac9a237b09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / iil_testkit-0.6.1-py3-none-any.whl

Download URL iil_testkit-0.6.1-py3-none-any.whl
Size 26.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb6f91b67c3726c8fd8593d538afa6b708a698bd4bc6336f791a85d47d47e149
BLAKE2b-256 checksum
How to use checksums
9fe9a508e6def5f541bde669e3937c655b4e5ee93364e0757a46baa4213a1e6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Security for iil-testkit 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for iil_testkit-0.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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