You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs/examples: __init__.py and helpers.py incorrectly collected as tests #796
pytest docs/examples/ --collect-only collects four __init__.py files and helper/helpers.py as test items. They're support files, not runnable examples.
Visible after #794 restored directory-level collection, but the root cause predates that — collection is exclusion-based, so any .py file without a skip marker gets collected.
Options
A. Explicit exclusion — add these files to examples_to_skip. Quick, but doesn't prevent the same problem with future support files.
B. Opt-in collection (recommended) — require a # pytest: marker for collection. Files without one are silently skipped. Given we can't set up prerequisites or interact during execution, only files that explicitly declare themselves runnable should be collected.
All existing examples already have the marker. Changes needed:
Skip files with no markers in pytest_collect_file / pytest_pycollect_makemodule
Remove # pytest: ollama, e2e from helper/helpers.py (not a standalone example)
One additional note - I've not removed the pytest lines from existing examples (where they were set to skip), and the skip marker is still supported for examples -- but the //default// is that we don't consider them a test - they're not even explicitly reported as being skipped (since that is noise).
Given examples are hard to run, and the comment-based framework doesn't have the richness of the actual pytests (for example the memory checking conditions etc). AND given that many exaples are hard to run as-is (dependencies etc) it seems pragmatic for now
I do think we should try to run more examples automatically - though we may move to running via shell scripts with additional setup, or may figure out a better convention for defining the equivilent of fixes to do pre/post processing for test setup (interested? I could raise issue for that to look at in future -- prioritizing WHICH examples would add focus)
Activity
planetf1 commentedon Apr 8, 2026
@jakelorocco @ajbozarth interested in your thoughts on option B? It feels the best compromise to me
ajbozarth commentedon Apr 8, 2026
I actually like the idea of defaulting to skip, removing the need to specify it directly
planetf1 commentedon Apr 9, 2026
Fixed alongside #794 in the same PR (#795). Went with option B (opt-in collection):
# pytest:marker are silently ignored during collectionhelper/helpers.py79 examples now collected (down from 84), no
__init__.pyorhelpers.pyin the output.fix: require # pytest: marker for example collection (generative-comp…
planetf1 commentedon Apr 9, 2026
One additional note - I've not removed the pytest lines from existing examples (where they were set to skip), and the skip marker is still supported for examples -- but the //default// is that we don't consider them a test - they're not even explicitly reported as being skipped (since that is noise).
Given examples are hard to run, and the comment-based framework doesn't have the richness of the actual pytests (for example the memory checking conditions etc). AND given that many exaples are hard to run as-is (dependencies etc) it seems pragmatic for now
I do think we should try to run more examples automatically - though we may move to running via shell scripts with additional setup, or may figure out a better convention for defining the equivilent of fixes to do pre/post processing for test setup (interested? I could raise issue for that to look at in future -- prioritizing WHICH examples would add focus)
fix: restore example collection during directory traversal (#794) (#795)
fix: restore example collection during directory traversal (generativ…