Testing plugin for funcnodes
Project description
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.nodetestMarks async node tests, injectspytest.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_testWraps sync or async tests that interact withfuncnodes_core/funcnodesstate (loading shelves, running flows, tweaking config). It toggles the same isolatedtest_contextused 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_teardownfixtures 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-onlyfilters 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 exittest_contextautomatically.
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_NODESis 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_funcnodes-1.1.0.tar.gz.
File metadata
- Download URL: pytest_funcnodes-1.1.0.tar.gz
- Upload date:
- Size: 46.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f3a9eab9d3df7158b773aa75a54a8caca1bbec92fa1cd9943505a2236d435af
|
|
| MD5 |
a713bdfab8cb0dcdf448585bf854a957
|
|
| BLAKE2b-256 |
ec7ac9a481b829d86b89cec6e78d97a8ddc8a155b32bb298113e011a2db990dd
|
Provenance
The following attestation bundles were made for pytest_funcnodes-1.1.0.tar.gz:
Publisher:
version_publish_main.yml on Linkdlab/funcnodes_pytest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_funcnodes-1.1.0.tar.gz -
Subject digest:
0f3a9eab9d3df7158b773aa75a54a8caca1bbec92fa1cd9943505a2236d435af - Sigstore transparency entry: 774628945
- Sigstore integration time:
-
Permalink:
Linkdlab/funcnodes_pytest@a2b1a9229ebdfb8faa95b4822a525ee3844fc845 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Linkdlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
version_publish_main.yml@a2b1a9229ebdfb8faa95b4822a525ee3844fc845 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_funcnodes-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_funcnodes-1.1.0-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce0a63d29218c3751051d73ea65a286cf5c4c9ec5886045c668084c71d477ab0
|
|
| MD5 |
94a6a77a5bcfa47eb0bd7225db13e60d
|
|
| BLAKE2b-256 |
28e671d9ec89409b12ac005be5104bfa267520b49c561ca976f38e1e9911bde4
|
Provenance
The following attestation bundles were made for pytest_funcnodes-1.1.0-py3-none-any.whl:
Publisher:
version_publish_main.yml on Linkdlab/funcnodes_pytest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_funcnodes-1.1.0-py3-none-any.whl -
Subject digest:
ce0a63d29218c3751051d73ea65a286cf5c4c9ec5886045c668084c71d477ab0 - Sigstore transparency entry: 774628946
- Sigstore integration time:
-
Permalink:
Linkdlab/funcnodes_pytest@a2b1a9229ebdfb8faa95b4822a525ee3844fc845 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Linkdlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
version_publish_main.yml@a2b1a9229ebdfb8faa95b4822a525ee3844fc845 -
Trigger Event:
push
-
Statement type: