muvid.subgenres.testing¶
A conformance kit for subgenre plugin authors.
Ship a contract and people will implement it slightly wrong; ship a contract
and a test that proves conformance and they won’t. pytest does this with
pytester, Datasette with datasette.utils.testing — this is the small
version.
In your plugin’s test suite:
from muvid.subgenres.testing import check_subgenre_conformance
from my_package.subgenre import MY_THING
def test_conformance(tmp_path):
report = check_subgenre_conformance(MY_THING, workdir=tmp_path)
assert report.ok, report.summary()
Pass render=False to check only the manifest — useful in a fast unit suite
where you don’t want to pay for a real render.
The module also provides echo_renderer(), a real (if trivial) renderer
used by muvid’s own tests and by this module’s doctests.
Functions
|
Check a manifest against the contract, and optionally run one render. |
|
A renderer that writes its request as JSON. |
Classes
|
What |
- class muvid.subgenres.testing.ConformanceReport(slug, passed=<factory>, failures=<factory>, skipped=<factory>)[source]¶
Bases:
objectWhat
check_subgenre_conformance()found.
- muvid.subgenres.testing.check_subgenre_conformance(subgenre, *, workdir, render=True, inputs=None, params=None)[source]¶
Check a manifest against the contract, and optionally run one render.
- Return type:
>>> import tempfile >>> sg = Subgenre(slug='conformance-demo', title='Demo', ... description='A demo.', ... render='muvid.subgenres.testing:echo_renderer', api_versions=("1",)) >>> with tempfile.TemporaryDirectory() as d: ... rep = check_subgenre_conformance(sg, workdir=d) >>> rep.ok True