Skip to main content

pytest-funcnodes

pytest_funcnodes is the maintained pytest plugin for FuncNodes modules. It replaces the legacy TestAllNodesBase harness by supplying decorators, fixtures, and coverage helpers that keep the runtime isolated and guarantee every node is exercised.

Key Features

  • @pytest_funcnodes.nodetest Marks async node tests, injects pytest.mark.asyncio, and records which node classes were covered. Every test that executes a node must use this decorator so the plugin can reset registries and track coverage.

  • @pytest_funcnodes.funcnodes_test Wraps sync or async tests that interact with funcnodes_core / funcnodes state (loading shelves, running flows, tweaking config). It toggles the same isolated test_context used for node tests, disabling file loggers and pointing configs at a per-test temp directory.

  • Autouse fixtures & CLI flag The plugin ships nodetest_setup_teardown / funcnodes_test_setup_teardown fixtures plus --nodetests-only, letting you run just node suites while keeping isolation guarantees.

  • Coverage helper pytest_funcnodes.all_nodes_tested(all_nodes, shelf, ignore=...) flattens shelves and asserts that every exported node class was covered by a @nodetest.

Installation

uv add pytest-funcnodes
# or
pip install pytest_funcnodes

Usage

1. Mark node tests

import pytest_funcnodes
import funcnodes as fn

@fn.NodeDecorator("demo.concat")
def concat(a: str, b: str) -> str:
    return a + b

@pytest_funcnodes.nodetest(concat)
async def test_concat():
    node = concat()
    node["a"] = "foo"
    node["b"] = "bar"
    await node
    assert node["out"].value == "foobar"

2. Mark runtime/integration tests

import pytest_funcnodes
from funcnodes_core import config as fnconfig

@pytest_funcnodes.funcnodes_test
def test_config_uses_temp_dir():
    cfg_dir = fnconfig.get_config_dir()
    assert cfg_dir.name.startswith("funcnodes_test_")

3. Enforce shelf coverage

from pytest_funcnodes import all_nodes_tested
import funcnodes_basic as fnmodule

def test_all_nodes_tested(all_nodes):
    all_nodes_tested(all_nodes, fnmodule.NODE_SHELF, ignore=[])

This assertion fails with a list of missing node classes if any exported node lacks a @nodetest.

4. CLI workflow

  • pytest --nodetests-only filters the run down to node suites.
  • The session fixture prints Session fixture setup/teardown, confirming the plugin activated.
  • No manual calls to funcnodes_core.testing.setup() / teardown() are required—the fixtures enter and exit test_context automatically.

Runtime Isolation Details

test_context (see pytest_funcnodes/testingsystem.py) rewrites the FuncNodes config directory into a temp folder per PID, clears leftovers between tests, disables file handlers, upgrades selected warnings (e.g., FuncNodesDeprecationWarning) to errors, and removes the temp directory on exit. This means:

  • Tests never leak global registry state (funcnodes_core.node.REGISTERED_NODES is cleared after each run).
  • File logs stay inside the temp dir and are removed after teardown.
  • Fail-fast behavior surfaces deprecated APIs that still fire warnings.

Always prefer the provided decorators over manual setup so these safeguards remain effective.

Metadata

Release files for pytest-funcnodes 1.1.0

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

Source distribution (sdist)

Source distribution for pytest-funcnodes 1.1.0
File Size Uploaded
pytest_funcnodes-1.1.0.tar.gz 46.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-funcnodes 1.1.0
File Interpreter ABI Platform
pytest_funcnodes-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 78.5 kB

Release files / pytest_funcnodes-1.1.0.tar.gz

Download URL pytest_funcnodes-1.1.0.tar.gz
Size 46.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0f3a9eab9d3df7158b773aa75a54a8caca1bbec92fa1cd9943505a2236d435af
BLAKE2b-256 checksum
How to use checksums
ec7ac9a481b829d86b89cec6e78d97a8ddc8a155b32bb298113e011a2db990dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 21, 2025.

Transparency log

Release files / pytest_funcnodes-1.1.0-py3-none-any.whl

Download URL pytest_funcnodes-1.1.0-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce0a63d29218c3751051d73ea65a286cf5c4c9ec5886045c668084c71d477ab0
BLAKE2b-256 checksum
How to use checksums
28e671d9ec89409b12ac005be5104bfa267520b49c561ca976f38e1e9911bde4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 21, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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