Software Testing / Learning brief

Tom moves shared set-up into a pytest conftest file

What this means in plain language

Tom moves a repeated sign-in into conftest.py, gives it a session scope and learns why a broad fixture cannot use a narrow one.

Understand the full idea, step by step

Analogy: a school corridor with a stationery cupboard. Every classroom on the corridor can take pens from the cupboard, and no one has to ask for a key. Pens bought for the whole term last all term. A pen handed out for one lesson goes back after that lesson.

The cupboard is the conftest file, and the length of time a supply lasts is its scope.

Evidence & review

REVIEWED 2026-10-31

The date on this lesson is when it went up on Payments Signal, not when its material was written — most of these were brought across from an earlier catalogue in a single run, which is why so many of them share a date. What the lesson says about the world is dated by the review above and by the sources below it.

Hands-on steps for this tool. The people and the app are invented.

What this brief simplifies: Selected primary passages actually read 7 November 2026; Selenium/version limits stated in lesson. Daily List, rules and observations are synthetic, not an executed live-app test.

Sources for this brief — 4 sources
  1. Implementation-specific

    pytest fixture guide ↗ — pytest-dev contributors · Scopes and parameter caching; yield-setup failure; broader/narrower dependency lifetimes (selected actual primary passages read 7 November 2026; live publisher documentation, not every linked section or historical release).

    Scopes and parameter caching; yield-setup failure; broader/narrower dependency lifetimes. Product/configuration-specific guidance; not a universal team practice. · Checked 2026-11-07

    Selected actual primary passages read, including the specific fixture/marker/collection boundaries described. Daily List rules, people and paths are synthetic; no pytest/xdist execution or complete production fixture design is claimed. Live documentation has no fixed edition claimed.

  2. Implementation-specific

    pytest fixture reference ↗ — pytest-dev contributors · Availability from requesting test perspective; conftest upward search and nearest applicable override (selected actual primary passages read 7 November 2026; live publisher documentation, not every linked section or historical release).

    Availability from requesting test perspective; conftest upward search and nearest applicable override. Product/configuration-specific guidance; not a universal team practice. · Checked 2026-11-07

    Selected actual primary passages read, including the specific fixture/marker/collection boundaries described. Daily List rules, people and paths are synthetic; no pytest/xdist execution or complete production fixture design is claimed. Live documentation has no fixed edition claimed.

  3. Implementation-specific

    pytest-xdist how-to ↗ — pytest-dev contributors · Session-scoped fixtures across separate workers; optional cross-process coordination example (selected actual primary passages read 7 November 2026; live publisher documentation, not every linked section or historical release).

    Session-scoped fixtures across separate workers; optional cross-process coordination example. Product/configuration-specific guidance; not a universal team practice. · Checked 2026-11-07

    Selected actual primary passages read, including the specific fixture/marker/collection boundaries described. Daily List rules, people and paths are synthetic; no pytest/xdist execution or complete production fixture design is claimed. Live documentation has no fixed edition claimed.

  4. Simplified educational illustration

    Payments Signal editorial teaching models — Payments Signal · Synthetic Daily List rule and observations stated in the lesson; not a publisher application fact or an executed live-app result.

    This site's own simplified teaching models. · Checked 2026-07-12

    Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.

Learn this properly

START HEREpytest conftest.py: share fixtures across files, and choose a fixture scopeMove set-up that many test files need into one conftest.py file, pick how long each fixture lives, and keep that file small so it stays easy to read.Opens at L0 Explain simply · about 16 min

Related briefs