Skip to content

fix(#648): the documented conftest import does not work — use a marker instead#657

Merged
ligon merged 1 commit into
developmentfrom
fix/648-conftest-import-marker
Jul 22, 2026
Merged

fix(#648): the documented conftest import does not work — use a marker instead#657
ligon merged 1 commit into
developmentfrom
fix/648-conftest-import-marker

Conversation

@ligon

@ligon ligon commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Self-inflicted, found by the #645 work on CI.

The bug

#648 added tests/conftest.py and documented:

from conftest import aws_creds_available

That resolves to the repo-root conftest.py — which is tracked, exists, and has no such function. The other obvious spelling, from tests.conftest import …, fails as tests.tests under pytest’s import mode here.

Both were tried on CI during the #645 fix and both failed. So the file whose entire purpose is to stop PRs going red for environmental non-reasons advertised an API that itself goes red. That agent worked around it by loading the module by path and — correctly — declined to patch shared test infra from inside an unrelated PR.

The fix: make it reachable without an import

  • register a requires_s3 marker in pytest_configure
  • add pytest_collection_modifyitems to skip marked items when credentials are absent

A test module now writes, and imports nothing:

pytestmark = pytest.mark.requires_s3

Verified both directions, because a guard that skips everywhere is worse than none:

result
creds present 1 passed — does not over-skip
creds absent (CI’s shape) 1 skipped, reason reported

The automatic pytest_runtest_makereport net from #648 is untouched and still catches modules that forget the marker entirely. This adds the explicit, declarative path that was advertised but unusable.

The docstring now records both broken spellings and why, so the next person does not re-derive them.

Refs #648, #645.

…r instead

PR #648 added `tests/conftest.py` and told test modules to do:

    from conftest import aws_creds_available

That does not work, and I shipped it merged. There is a tracked **repo-root**
`conftest.py`, so the bare name resolves to THAT file, which has no such
function. The other obvious spelling, `from tests.conftest import ...`, fails as
`tests.tests` under pytest's import mode here. Both were tried on CI by the #645
work and both failed — the exact class of breakage #648 exists to prevent, in
#648 itself.

Fix: make the guard reachable WITHOUT an import.

  * register a `requires_s3` marker in `pytest_configure`;
  * add `pytest_collection_modifyitems` to skip marked items when credentials
    are absent.

A test module now writes:

    pytestmark = pytest.mark.requires_s3

and imports nothing. The docstring records both broken spellings so the next
person does not re-derive them.

Verified both directions:

    creds present : 1 passed   (marker does not over-skip)
    creds absent  : 1 skipped  (CI's shape, reason reported)

The automatic `pytest_runtest_makereport` net from #648 is unchanged and still
catches modules that forget the marker entirely; this adds the explicit,
declarative path that was advertised but unusable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ligon
ligon merged commit 212340b into development Jul 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant