pytest-openfeature
Drive pytest configuration from an OpenFeature
provider. Resolve registered pytest options (CLI and ini) at session start so a
single feature-flag service can steer your test fleet — most obviously,
pytest-randomly's --randomly-seed, but any registered option works.
Status: early/draft. The API and configuration surface may change before 1.0.
Why
You have a fleet of CI runs and you'd like to:
- Pin them all to the same
--randomly-seedfor a day, then roll forward. - Flip
-xon for a subset of branches without editing every workflow. - Roll out a
pytestinvocation tweak gradually using your existing flag service's targeting rules.
pytest-openfeature resolves a flag from any spec-compliant OpenFeature
provider and writes its value into the matching pytest option before the
plugin chain reads it.
Install
pip install pytest-openfeature
# plus any OpenFeature provider you use, e.g.:
pip install openfeature-provider-flagd
Quick start
# pyproject.toml
[tool.pytest_openfeature]
strict = false
[tool.pytest_openfeature.flags]
"ci.pytest_randomly_seed" = "randomly_seed"
[tool.pytest_openfeature.provider]
type = "flagd"
endpoint = "https://flagd.internal/eu"
$ pytest tests/
openfeature: provider=flagd, 1 flag resolved
randomly_seed <-- ci.pytest_randomly_seed = 20260427 (TARGETING_MATCH)
Using --randomly-seed=20260427
================== test session starts ==================
A developer overriding the flag locally still wins:
$ pytest --randomly-seed=42 tests/
CLI > PYTEST_ADDOPTS > OpenFeature > ini > pytest default.
Configuration
| key | type | default | meaning |
|---|---|---|---|
auto_resolve |
bool | true |
Resolve any flag whose key matches a pytest option name. |
strict |
bool | false |
Fail the run on resolution errors instead of falling back. |
domain |
str | "" |
OpenFeature client domain. |
flags |
table | {} |
Explicit flag_key = pytest_option mapping. |
resolve_timeout |
float | 1.0 |
Per-resolution timeout in seconds. |
override_addopts |
bool | false |
Allow OF to inject CLI tokens before parsing. |
addopts_merge |
str | "append" |
append / prepend / replace. |
addopts_flag_key |
str | "pytest.addopts" |
Flag key for the addopts slot. |
provider |
table | none | Provider bootstrap (type, plus kwargs). |
Equivalent ini keys ([pytest] / [tool:pytest] / setup.cfg) all start with
openfeature_. Env vars use PYTEST_OPENFEATURE_*.
Hooks
Plugin authors can register a provider or modify the evaluation context from a
project's conftest.py:
def pytest_openfeature_provider(config):
from my_provider import MyProvider
return MyProvider(api_key=os.environ["FF_KEY"])
def pytest_openfeature_context(config, context):
context.attributes["team"] = "platform"
return context
Fixtures
openfeature_client exposes the session-scoped client to your tests when you
want to consult flags from inside a test.
License
MIT
Metadata
Release files for pytest-openfeature 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_openfeature-0.1.1.tar.gz | 19.2 kB | With provenance | Details for pytest_openfeature-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_openfeature-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_openfeature-0.1.1-py3-none-any.whl |
Total release size: 39.0 kB
Release files / pytest_openfeature-0.1.1.tar.gz
| Download URL | pytest_openfeature-0.1.1.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e49180e72f2cc59fb780a2863133f4ba1a7e3d4a0525d40e6c92ddbfdf6cee3
|
|
BLAKE2b-256 checksum How to use checksums |
b9043986c076d37325cf056da1182c5e2e52c8dfa24bc5ee91353846d9c96aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Apr 28, 2026.
Transparency logRelease files / pytest_openfeature-0.1.1-py3-none-any.whl
| Download URL | pytest_openfeature-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
041070697963410259fecf4e0d85ee1673e0634f6c9271a02a458b6cf3dc56e7
|
|
BLAKE2b-256 checksum How to use checksums |
d9951edd9bd3a49f6a0c70555d5ebfb1b88f13a29f9ae0d495eb255c11c74219
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Apr 28, 2026.
Transparency logSecurity for pytest-openfeature 0.1.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.
Attestation for pytest_openfeature-0.1.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 Apr 28, 2026.
Transparency logA 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.