Skip to content

Add a Testing API reference (plone.app.testing + plone.testing) - #2097

Open
jensens wants to merge 5 commits into
backend-testing-docsfrom
plone-app-testing-docs
Open

Add a Testing API reference (plone.app.testing + plone.testing)#2097
jensens wants to merge 5 commits into
backend-testing-docsfrom
plone-app-testing-docs

Conversation

@jensens

@jensens jensens commented Jul 24, 2026

Copy link
Copy Markdown
Member

Builds on #2094 (the backend testing chapter). Targets backend-testing-docs; merge #2094 first. GitHub will retarget this to 6.0 once #2094 lands.

What

Adds an autodoc-generated API reference and a deeper layer-model explanation to the developer-guide/testing chapter, plus two how-tos. It covers both testing packages as one toolkit, because a test author does not care whether a symbol lives in plone.app.testing or plone.testing.

Page
testing-api-reference.md Organized by task: layer model, pre-built layers & fixtures, browser & HTTP, helpers, sandboxing primitives, constants. Symbols documented at their canonical location (e.g. pushGlobalRegistry under plone.testing.zca, with a re-export note), from both packages.
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 absorbing the test-specific patterns from plone.app.testing's README.

How the reference is built

sphinx-autodoc2, which analyses the sources statically. So:

  • No Plone is installed in the docs build. sphinx.ext.autodoc would need to import plone.app.testing, which pulls in ~226 packages (all of Plone). autodoc2 needs neither. Both packages are added as source-only submodules.
  • It coexists with the existing sphinx.ext.autodoc (used by plone.api).
  • The plone.testing submodule pins master; the Layer class 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

  • Browser is a re-export from a private module (plone.testing._z2_testbrowser), which autodoc2 cannot resolve, so it is documented as a short prose entry.
  • Legacy ZServer (PLONE_ZSERVER, PLONE_FTP_SERVER) is noted, not documented — Plone 6 runs on WSGI.
  • Vale is clean on the new pages; the vocabulary additions it needed are included and sorted.

🤖 Generated with Claude Code

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 gforcada left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! 🌟 I have only a few suggestions for improvements rather than blockers 👍🏾

Comment thread requirements.txt Outdated
Comment thread docs/conf.py Outdated
Comment thread docs/developer-guide/testing/index.md Outdated
Comment thread docs/developer-guide/testing/how-testing-layers-work.md Outdated
Comment thread docs/developer-guide/testing/install-add-ons-in-tests.md
Comment thread docs/developer-guide/testing/testing-api-reference.md Outdated
Comment thread docs/developer-guide/testing/drive-the-test-browser.md Outdated
jensens added 2 commits July 28, 2026 15:06
- 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.
@jensens

jensens commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Thanks @gforcada! Addressed in the last commit:

  • requirements.txt — sorted sphinx-autodoc2 into place.
  • conf.py comment — good point about it outdating. Made the comments generic ("static API docs from source, no package import needed") instead of naming a specific consumer, so they stay true no matter which packages use autodoc2.
  • "which both packages?" — now names them: "across plone.app.testing and plone.testing".
  • pytest note — made it a {tip}.
  • Blicca — done, and thanks for the nudge: "Blicca, the frontend formerly called Classic UI", with a link to the Volto testing docs for the other side. (The rest of the docs still say "Classic UI", so this page is slightly ahead — happy to align once the wider rename lands.)

Two where I did something a bit different, curious what you think:

  • defaultBases vs bases — they aren't quite the same purpose, so rather than drop one I clarified when each applies: you set defaultBases on a reusable layer class, and pass bases only when instantiating a layer directly to combine existing ones (the exception, not the rule). That should answer the "which one" question without hiding the override.
  • The intro "documented at its canonical location" note — I kept it as prose rather than a third admonition. The page already has two (the legacy-ZServer warning and the re-export note), and the Plone docs style guide asks for admonitions sparingly, so I didn't want to spend a third on orientation text. Easy to switch if you feel strongly.

The previous review fix silently no-op'd (the search text omitted a word),
so the line still read 'from both packages'. Name plone.app.testing and
plone.testing explicitly, as intended.
@github-project-automation github-project-automation Bot moved this from New to Approved in Plone Documentation Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

2 participants