Add a Testing API reference (plone.app.testing + plone.testing) - #2097
Add a Testing API reference (plone.app.testing + plone.testing)#2097jensens wants to merge 4 commits into
Conversation
Extends the developer-guide/testing chapter with an autodoc-generated API reference and a deeper layer-model explanation, covering both testing packages as one toolkit (a test author does not care which package a symbol lives in). - testing-api-reference.md: organized by task (layer model, pre-built layers and fixtures, browser and HTTP, helpers, sandboxing primitives, constants), pulling symbols from both packages at their canonical location, with re-exports noted. Generated by sphinx-autodoc2, which reads the sources statically -- so no Plone is installed in the docs build. Both packages are added as source-only submodules. - how-testing-layers-work.md: deepened with the fixture/lifecycle split. - install-add-ons-in-tests.md, drive-the-test-browser.md: two how-tos that absorb the test-specific patterns from plone.app.testing's README. conf.py gains the autodoc2 extension beside the existing sphinx.ext.autodoc (used by plone.api); the two coexist. Legacy ZServer is noted, not documented. Vale is clean on the new pages.
gforcada
left a comment
There was a problem hiding this comment.
Very nice! 🌟 I have only a few suggestions for improvements rather than blockers 👍🏾
| sphinxext-opengraph | ||
| sphinxcontrib.mermaid | ||
| vale | ||
| sphinx-autodoc2 # developer-guide/testing plone.app.testing reference |
| # Don't show class signature with the class' name. | ||
| autodoc_class_signature = "separated" | ||
|
|
||
| # -- Options for autodoc2 (plone.app.testing reference) ----------------------- |
There was a problem hiding this comment.
While nice for the PR itself, it might outdate very quickly this constant reference that autodoc2 is added due to plone.app.testing. As soon, say, plone.api is used as well, we will not go around and update all the references.
git blame is much better at that for this purpose IMHO
|
|
||
| ## Reference and background | ||
|
|
||
| - {doc}`testing-api-reference`: the layers, fixtures, helpers, and sandboxing, from both packages. |
|
|
||
| ## Layers compose through bases | ||
|
|
||
| A layer declares its bases—the layers it builds on—through `defaultBases` or the `bases` argument. |
There was a problem hiding this comment.
If both (defaultBases and bases) serve the same purpose (which I have no idea right now) should we only mention one? Otherwise readers might just wonder exactly that: which one to use 🤷🏾 ?
| It uses the helpers from {doc}`testing-api-reference`. | ||
| The examples assume a layer whose fixture already loaded your add-on's ZCML—see {doc}`write-a-testing-layer`. | ||
|
|
||
| If you use pytest, {doc}`pytest-plone </developer-guide/testing/pytest>` also offers an `installer` fixture and an `@pytest.mark.portal(profiles=[...])` marker that do the same thing with less boilerplate. |
There was a problem hiding this comment.
that could be an admonition? to better highlight it?
| You import from whichever package a symbol lives in, but from a test author's point of view they are one toolkit, so this page is organized by task rather than by package. | ||
| Each symbol is documented at its canonical location; re-exports are noted. |
There was a problem hiding this comment.
that should be an admonition IMHO
|
|
||
| ```{important} | ||
| `zope.testbrowser` runs entirely in Python and does **not** run JavaScript. | ||
| Use it for server-rendered pages (Classic UI). To test a Volto frontend, use the Volto documentation's end-to-end testing tools instead. |
There was a problem hiding this comment.
Should we already name Blicca here? otherwise we keep the old name still around...
As for the Volto docs, do we have a link within the docs we can point to? 🤔
There was a problem hiding this comment.
we should at least name both Blicca (formelry ClassicUI) or such.
- Sort sphinx-autodoc2 into requirements.txt. - Make the autodoc2 conf.py comments generic instead of naming a specific consumer, which would outdate. - Name the two packages explicitly in the chapter index instead of 'both packages'. - Clarify defaultBases vs the bases argument (class default vs the instantiation-time exception) rather than listing them as equivalent. - Highlight the pytest alternative in the install how-to as a tip. - Name Blicca (formerly Classic UI) and link the Volto testing docs in the test-browser how-to. Kept the reference intro as prose rather than a third admonition, per the Plone docs guidance to use admonitions sparingly.
|
Thanks @gforcada! Addressed in the last commit:
Two where I did something a bit different, curious what you think:
|
Builds on #2094 (the backend testing chapter). Targets
backend-testing-docs; merge #2094 first. GitHub will retarget this to6.0once #2094 lands.What
Adds an autodoc-generated API reference and a deeper layer-model explanation to the
developer-guide/testingchapter, plus two how-tos. It covers both testing packages as one toolkit, because a test author does not care whether a symbol lives inplone.app.testingorplone.testing.testing-api-reference.mdpushGlobalRegistryunderplone.testing.zca, with a re-export note), from both packages.how-testing-layers-work.mdinstall-add-ons-in-tests.md,drive-the-test-browser.mdplone.app.testing's README.How the reference is built
sphinx-autodoc2, which analyses the sources statically. So:sphinx.ext.autodocwould need to importplone.app.testing, which pulls in ~226 packages (all of Plone). autodoc2 needs neither. Both packages are added as source-only submodules.sphinx.ext.autodoc(used byplone.api).plone.testingsubmodule pins master; theLayerclass docstring there is currently a one-liner. Expand the Layer base class docstring plone.testing#134 enriches it, after which a submodule bump renders it in full. The reference is complete either way; that entry just gets richer.Notes
Browseris a re-export from a private module (plone.testing._z2_testbrowser), which autodoc2 cannot resolve, so it is documented as a short prose entry.PLONE_ZSERVER,PLONE_FTP_SERVER) is noted, not documented — Plone 6 runs on WSGI.🤖 Generated with Claude Code